utils
normalize_proba(p)
Make sure the probability array respects the following constraints: - the sum of each column must be equal to 1 (or very close to 1)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
array
|
The probability array to normalize |
required |
Returns:
| Type | Description |
|---|---|
array
|
The normalized array |
Source code in badgers/core/utils.py
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | |
random_sign(random_generator=default_rng(0), size=(1,))
Generates an array full of ones, with randomly assigned signs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
random_generator
|
Generator
|
a random number generator |
default_rng(0)
|
size
|
Tuple[int]
|
the shape of the array to generate |
(1,)
|
Returns:
| Type | Description |
|---|---|
array
|
an array full of ones, with randomly assigned signs |
Source code in badgers/core/utils.py
26 27 28 29 30 31 32 33 34 35 36 37 | |
random_spherical_coordinate(random_generator=default_rng(0), size=None, radius=None)
Randomly generates points on a hypersphere of dimension size
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
random_generator
|
Generator
|
a random number generator |
default_rng(0)
|
size
|
int
|
the dimension of the hypersphere |
None
|
radius
|
float
|
the radius of the hypersphere |
None
|
Returns:
| Type | Description |
|---|---|
array
|
an array of shape ( |
Source code in badgers/core/utils.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | |