util
get_rng(rng=None)
Retrieves or generate with a seed a random number generator RNG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
int or Generator
|
A seed for random generation or directly a numpy random generator. |
= np.random.default_rng()
|
Returns:
| Name | Type | Description |
|---|---|---|
rng |
Generator
|
A Generator instance. |
Source code in olfactory_navigation/util.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
random_choice(rng, a, size=1, replace=True, p=None)
A drop-in replacement for the rng.choice function that interchangeably accepts numpy or cupy arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
rng
|
Generator
|
The random generator to use. |
required |
a
|
ndarray
|
The array to choose items out of. |
required |
size
|
int | tuple[int]
|
How many items are to be chosen. |
= 1
|
replace
|
bool
|
Whether the items can be chosen after being picked already. |
= True
|
p
|
ndarray
|
Probability distributions to be applied to the elements |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
description |
Source code in olfactory_navigation/util.py
34 35 36 37 38 39 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 | |