Space Engineers
Classes | Public Member Functions | Properties | List of all members
VRage.Utils.MyDiscreteSampler< T > Class Template Reference

A templated class for sampling from a set of objects with given probabilities. Uses MyDiscreteSampler. More...

Inheritance diagram for VRage.Utils.MyDiscreteSampler< T >:

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)
 
Sample (MyRandom rng)
 
Sample (float sample)
 
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]
 

Detailed Description

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.

Constructor & Destructor Documentation

VRage.Utils.MyDiscreteSampler< T >.MyDiscreteSampler ( T[]  values,
IEnumerable< float >  densities 
)
inline

Definition at line 28 of file MyDiscreteSampler.cs.

VRage.Utils.MyDiscreteSampler< T >.MyDiscreteSampler ( List< T >  values,
IEnumerable< float >  densities 
)
inline

Definition at line 37 of file MyDiscreteSampler.cs.

VRage.Utils.MyDiscreteSampler< T >.MyDiscreteSampler ( IEnumerable< T >  values,
IEnumerable< float >  densities 
)
inline

Definition at line 49 of file MyDiscreteSampler.cs.

VRage.Utils.MyDiscreteSampler< T >.MyDiscreteSampler ( Dictionary< T, float >  densities)
inline

Definition at line 64 of file MyDiscreteSampler.cs.

Definition at line 139 of file MyDiscreteSampler.cs.

VRage.Utils.MyDiscreteSampler< T >.MyDiscreteSampler ( int  prealloc)
inline

Definition at line 146 of file MyDiscreteSampler.cs.

Member Function Documentation

IEnumerator<T> VRage.Utils.MyDiscreteSampler< T >.GetEnumerator ( )
inline

Definition at line 84 of file MyDiscreteSampler.cs.

void VRage.Utils.MyDiscreteSampler< T >.Prepare ( IEnumerable< float >  densities)
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.

T VRage.Utils.MyDiscreteSampler< T >.Sample ( MyRandom  rng)
inline

Definition at line 67 of file MyDiscreteSampler.cs.

T VRage.Utils.MyDiscreteSampler< T >.Sample ( float  sample)
inline

Definition at line 72 of file MyDiscreteSampler.cs.

T VRage.Utils.MyDiscreteSampler< T >.Sample ( )
inline

Definition at line 77 of file MyDiscreteSampler.cs.

int VRage.Utils.MyDiscreteSampler< T >.Sample ( MyRandom  rng)
inline

Definition at line 226 of file MyDiscreteSampler.cs.

int VRage.Utils.MyDiscreteSampler< T >.Sample ( float  rate)
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.

int VRage.Utils.MyDiscreteSampler< T >.Sample ( )
inline

Definition at line 269 of file MyDiscreteSampler.cs.

Property Documentation

int VRage.Utils.MyDiscreteSampler< T >.Count
get

Definition at line 82 of file MyDiscreteSampler.cs.

bool VRage.Utils.MyDiscreteSampler< T >.Initialized
get

Definition at line 21 of file MyDiscreteSampler.cs.


The documentation for this class was generated from the following file: