docs.unity3d.com
    Show / Hide Table of Contents

    Class SamplerUtility

    A set of utility functions for defining sampler interfaces

    Inheritance
    Object
    SamplerUtility
    Namespace: UnityEngine.Perception.Randomization.Samplers
    Syntax
    public static class SamplerUtility : object

    Fields

    largePrime

    A large prime number

    Declaration
    public const uint largePrime = null
    Field Value
    Type Description
    UInt32

    samplingBatchSize

    The number of samples to generate per job batch in an IJobParallelForBatch job

    Declaration
    public const int samplingBatchSize = null
    Field Value
    Type Description
    Int32

    Methods

    AnimationCurveSample(Single[], Single, Single, Single, Single)

    Generate samples from probability distribution derived from a given AnimationCurve.

    Declaration
    public static float AnimationCurveSample(float[] integratedCurve, float uniformSample, float interval, float startTime, float endTime)
    Parameters
    Type Name Description
    Single[] integratedCurve

    Numerical integration representing the AnimationCurve

    Single uniformSample

    A sample value between 0 and 1 generated from a uniform distribution

    Single interval

    The interval at which the original AnimationCurve was sampled in order to produce integratedCurve

    Single startTime

    The time attribute of the first key of the original AnimationCurve

    Single endTime

    The time attribute of the last key of the original AnimationCurve

    Returns
    Type Description
    Single

    The generated sample

    GenerateRandomSeed()

    Non-deterministically generates a non-zero random seed

    Declaration
    public static uint GenerateRandomSeed()
    Returns
    Type Description
    UInt32

    A non-deterministically generated random seed

    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

    Hash32(UInt32)

    Hashes using constants generated from a program that maximizes the avalanche effect, independence of output bit changes, and the probability of a change in each output bit if any input bit is changed. Source: https://github.com/h2database/h2database/blob/master/h2/src/test/org/h2/test/store/CalculateHashConstant.java

    Declaration
    public static uint Hash32(uint x)
    Parameters
    Type Name Description
    UInt32 x

    Unsigned integer to hash

    Returns
    Type Description
    UInt32

    The calculated hash value

    Hash32NonZero(UInt32)

    Generates a 32-bit non-zero hash using an unsigned integer seed

    Declaration
    public static uint Hash32NonZero(uint seed)
    Parameters
    Type Name Description
    UInt32 seed

    The unsigned integer to hash

    Returns
    Type Description
    UInt32

    The calculated hash value

    Hash64(UInt64)

    Based on splitmix64: http://xorshift.di.unimi.it/splitmix64.c

    Declaration
    public static ulong Hash64(ulong x)
    Parameters
    Type Name Description
    UInt64 x

    64-bit value to hash

    Returns
    Type Description
    UInt64

    The calculated hash value

    IntegrateCurve(Single[], AnimationCurve)

    Numerically integrate a given AnimationCurve using the specified number of samples. Based on https://en.wikipedia.org/wiki/Numerical_integration and http://blog.s-schoener.com/2018-05-05-animation-curves/ Using the trapezoidal rule for numerical interpolation

    Declaration
    public static void IntegrateCurve(float[] array, AnimationCurve curve)
    Parameters
    Type Name Description
    Single[] array

    The array to fill with integrated values

    AnimationCurve curve

    The animation curve to sample integrate

    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

    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023