Space Engineers
|
A templated class for sampling from a set of objects with given probabilities. Uses MyDiscreteSampler. More...
Public Member Functions | |
MyDiscreteSampler (T[] values, IEnumerable< float > densities) | |
MyDiscreteSampler (List< T > values, IEnumerable< float > densities) | |
MyDiscreteSampler (IEnumerable< T > values, IEnumerable< float > densities) | |
MyDiscreteSampler (Dictionary< T, float > densities) | |
T | Sample (MyRandom rng) |
T | Sample (float sample) |
T | Sample () |
IEnumerator< T > | GetEnumerator () |
MyDiscreteSampler () | |
MyDiscreteSampler (int prealloc) | |
void | Prepare (IEnumerable< float > densities) |
The list supplied to the method does not have to add up to 1.0f, that's why it's called "densities" instead of "probabilities". More... | |
int | Sample (MyRandom rng) |
int | Sample (float rate) |
int | Sample () |
Properties | |
bool | Initialized [get] |
int | Count [get] |
A templated class for sampling from a set of objects with given probabilities. Uses MyDiscreteSampler.
Provides a simple and efficient way of sampling a discrete probability distribution as described in http://www.jstatsoft.org/v11/i03/paper Instances can be reused by calling the Prepare method every time you want to change the distribution. Sampling a value is O(1), while the storage requirements are O(N), where N is number of possible values
Definition at line 15 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 28 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 37 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 49 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 64 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 139 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 146 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 84 of file MyDiscreteSampler.cs.
|
inline |
The list supplied to the method does not have to add up to 1.0f, that's why it's called "densities" instead of "probabilities".
Definition at line 153 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 67 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 72 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 77 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 226 of file MyDiscreteSampler.cs.
|
inline |
Beware that Cestmir thinks this can be less precise if you have a billiard numbers.
He is probably right. So only use this version if you don't care.
Definition at line 246 of file MyDiscreteSampler.cs.
|
inline |
Definition at line 269 of file MyDiscreteSampler.cs.
|
get |
Definition at line 82 of file MyDiscreteSampler.cs.
|
get |
Definition at line 21 of file MyDiscreteSampler.cs.