Class SamplerUtility
A set of utility functions for defining sampler interfaces
Inherited Members
Namespace: UnityEngine.Experimental.Perception.Randomization.Samplers
Syntax
public static class SamplerUtility
Methods
GenerateRandomSeed()
Non-deterministically generates a non-zero random seed
Declaration
public static uint GenerateRandomSeed()
Returns
Type | Description |
---|---|
UInt32 | A non-deterministically generated random seed |
GenerateSamples<T>(T, Int32, out JobHandle)
Schedules a multi-threaded job to generate an array of samples
Declaration
public static NativeArray<float> GenerateSamples<T>(T sampler, int sampleCount, out JobHandle jobHandle)
where T : struct, ISampler
Parameters
Type | Name | Description |
---|---|---|
T | sampler | The sampler to generate samples from |
Int32 | sampleCount | The number of samples to generate |
JobHandle | jobHandle | The handle of the scheduled job |
Returns
Type | Description |
---|---|
NativeArray<Single> | A NativeArray of generated samples |
Type Parameters
Name | Description |
---|---|
T | The type of sampler to sample |
GetSamplerDisplayName(Type)
Returns the sampler's display name
Declaration
public static string GetSamplerDisplayName(Type samplerType)
Parameters
Type | Name | Description |
---|---|---|
Type | samplerType | The sampler type |
Returns
Type | Description |
---|---|
String | The display name |
IterateSeed(UInt32, UInt32)
Generates new a new non-zero random state by deterministically hashing a base seed with an iteration index
Declaration
public static uint IterateSeed(uint index, uint baseSeed)
Parameters
Type | Name | Description |
---|---|---|
UInt32 | index | Usually the current scenario iteration or framesSinceInitialization |
UInt32 | baseSeed | The seed to be offset |
Returns
Type | Description |
---|---|
UInt32 | A new random state |
TruncatedNormalSample(Single, Single, Single, Single, Single)
Generates samples from a truncated normal distribution. Further reading about this distribution can be found here: https://en.wikipedia.org/wiki/Truncated_normal_distribution
Declaration
public static float TruncatedNormalSample(float uniformSample, float min, float max, float mean, float stdDev)
Parameters
Type | Name | Description |
---|---|---|
Single | uniformSample | A sample value between 0 and 1 generated from a uniform distribution |
Single | min | The minimum possible value to generate |
Single | max | The maximum possible value to generate |
Single | mean | The mean of the normal distribution |
Single | stdDev | The standard deviation of the normal distribution |
Returns
Type | Description |
---|---|
Single | A value sampled from a truncated normal distribution |
Exceptions
Type | Condition |
---|---|
ArgumentException |