Aardvark.Base


IRandomUniformExtensions

Static members

Static memberDescription
CreatePermutationArray(rnd, count)
Signature: (rnd:IRandomUniform * count:int) -> int []

Creates an array that contains a random permutation of the ints in the interval [0, count-1].

CreatePermutationArrayLong(rnd, count)
Signature: (rnd:IRandomUniform * count:int64) -> int64 []

Creates an array that contains a random permutation of the numbers in the interval [0, count-1].

CreateRandomSubsetOfSize(...)
Signature: (array:'T [] * subsetCount:int64 * rnd:IRandomUniform) -> 'T []
Type parameters: 'T

Returns a random subset of an array with a supplied number of elements (subsetCount). The elements in the subset are in the same order as in the original array. O(count). NOTE: this method needs to generate one random number for each element of the original array. If subsetCount is signficantly smaller than count, it is more efficient to use or or or .

CreateSmallRandomOrderedSubsetIndexArray(...)
Signature: (rnd:IRandomUniform * subsetCount:int * count:int) -> int []

Creates an ordered array of subsetCount int indices that constitute a subset of all ints in the range [0, count-1]. O(subsetCount * log(subsetCount)) for subsetCount << count. NOTE: It is assumed that subsetCount is significantly smaller than count. If this is not the case, use CreateRandomSubsetOfSize instead. WARNING: As subsetCount approaches count execution time increases significantly.

CreateSmallRandomOrderedSubsetIndexArrayLong(...)
Signature: (rnd:IRandomUniform * subsetCount:int64 * count:int64) -> int64 []

Creates an ordered array of subsetCount long indices that constitute a subset of all longs in the range [0, count-1]. O(subsetCount * log(subsetCount)) for subsetCount << count. NOTE: It is assumed that subsetCount is significantly smaller than count. If this is not the case, use CreateRandomSubsetOfSize instead. WARNING: As subsetCount approaches count execution time increases significantly.

CreateSmallRandomSubsetIndexArray(...)
Signature: (rnd:IRandomUniform * subsetCount:int * count:int) -> int []

Creates an unordered array of subsetCount int indices that constitute a subset of all ints in the range [0, count-1]. O(subsetCount) for subsetCount << count. NOTE: It is assumed that subsetCount is significantly smaller than count. If this is not the case, use CreateRandomSubsetOfSize instead. WARNING: As subsetCount approaches count execution time increases significantly.

CreateSmallRandomSubsetIndexArrayLong(...)
Signature: (rnd:IRandomUniform * subsetCount:int64 * count:int64) -> int64 []

Creates an unordered array of subsetCount long indices that constitute a subset of all longs in the range [0, count-1]. O(subsetCount) for subsetCount << count. NOTE: It is assumed that subsetCount is significantly smaller than count. If this is not the case, use CreateRandomSubsetOfSize instead. WARNING: As subsetCount approaches count execution time increases significantly.

CreateUniformDoubleArray(rnd, length)
Signature: (rnd:IRandomUniform * length:int64) -> float []

Create a random array of doubles in the half-open interval [0.0, 1.0) of the specified length.

CreateUniformDoubleFullArray(...)
Signature: (rnd:IRandomUniform * length:int64) -> float []

Create a random array of full doubles in the half-open interval [0.0, 1.0) of the specified length.

FillUniform(rnd, array)
Signature: (rnd:IRandomUniform * array:int []) -> unit

Fills the specified array with random ints in the interval [0, 2^31-1].

FillUniform(rnd, array)
Signature: (rnd:IRandomUniform * array:float32 []) -> unit

Fills the specified array with random floats in the half-open interval [0.0f, 1.0f).

FillUniform(rnd, array)
Signature: (rnd:IRandomUniform * array:float []) -> unit

Fills the specified array with random doubles in the half-open interval [0.0, 1.0).

FillUniformFull(rnd, array)
Signature: (rnd:IRandomUniform * array:float []) -> unit

Fills the specified array with fully random doubles (53 random bits) in the half-open interval [0.0, 1.0).

RandomBit(rnd, randomBits)
Signature: (rnd:IRandomUniform * randomBits:byref<int>) -> bool

Supply random bits one at a time. The currently unused bits are maintained in the supplied reference parameter. Before the first call randomBits must be 0.

Randomize(rnd, array, count)
Signature: (rnd:IRandomUniform * array:'T [] * count:int64) -> unit
Type parameters: 'T

Randomly permute the first count elements of the supplied array. This does work with counts of up to about 2^50.

Randomize(rnd, array)
Signature: (rnd:IRandomUniform * array:'T []) -> unit
Type parameters: 'T

Randomly permute the elements of the supplied array. This does work with arrays up to a length of about 2^50.

Randomize(rnd, list)
Signature: (rnd:IRandomUniform * list:List<'T>) -> unit
Type parameters: 'T

Randomly permute the elements of the supplied list.

Randomize(rnd, array, start, count)
Signature: (rnd:IRandomUniform * array:'T [] * start:int * count:int) -> unit
Type parameters: 'T

Randomly permute the specified number of elements in the supplied array starting at the specified index.

Randomize(rnd, array, start, count)
Signature: (rnd:IRandomUniform * array:'T [] * start:int64 * count:int64) -> unit
Type parameters: 'T

Randomly permute the specified number of elements in the supplied array starting at the specified index.

Randomize(rnd, list, start, count)
Signature: (rnd:IRandomUniform * list:List<'T> * start:int * count:int) -> unit
Type parameters: 'T

Randomly permute the specified number of elements in the supplied list starting at the specified index.

UniformC3f(rnd)
Signature: rnd:IRandomUniform -> C3f
UniformC3fClosed(rnd)
Signature: rnd:IRandomUniform -> C3f
UniformC3fOpen(rnd)
Signature: rnd:IRandomUniform -> C3f
UniformDoubleFull(rnd)
Signature: rnd:IRandomUniform -> float

Returns a uniformly distributed double in the half-open interval [0.0, 1.0). Note, that two random values are used to make all 53 bits random. If you use this repeatedly, consider using a 64-bit random generator, which can provide such doubles directly using UniformDouble().

UniformDoubleFullClosed(rnd)
Signature: rnd:IRandomUniform -> float

Returns a uniformly distributed double in the closed interval [0.0, 1.0]. Note, that two random values are used to make all 53 bits random.

UniformDoubleFullOpen(rnd)
Signature: rnd:IRandomUniform -> float

Returns a uniformly distributed double in the open interval (0.0, 1.0). Note, that two random values are used to make all 53 bits random.

UniformInt(rnd, size)
Signature: (rnd:IRandomUniform * size:int) -> int

Returns a uniformly distributed int in the interval [0, count-1]. In order to avoid excessive aliasing, two random numbers are used when count is greater or equal 2^24 and the random generator delivers 32 random bits or less. The method thus works fairly decently for all integers.

UniformIntNonZero(rnd)
Signature: rnd:IRandomUniform -> int

Returns a uniform int which is guaranteed not to be zero.

UniformLong(rnd, size)
Signature: (rnd:IRandomUniform * size:int64) -> int64

Returns a uniformly distributed long in the interval [0, size-1]. NOTE: If count has more than about 48 bits, aliasing leads to noticeable (greater 5%) shifts in the probabilities (i.e. one long has a probability of x and the other a probability of x * (2^(52-b)-1)/(2^(52-b)), where b is log(size)/log(2)).

UniformLongNonZero(rnd)
Signature: rnd:IRandomUniform -> int64

Returns a uniform long which is guaranteed not to be zero.

UniformV2d(rnd)
Signature: rnd:IRandomUniform -> V2d
UniformV2d(rnd, box)
Signature: (rnd:IRandomUniform * box:Box2d) -> V2d
UniformV2dClosed(rnd)
Signature: rnd:IRandomUniform -> V2d
UniformV2dClosed(rnd, box)
Signature: (rnd:IRandomUniform * box:Box2d) -> V2d
UniformV2dDirection(rnd)
Signature: rnd:IRandomUniform -> V2d
UniformV2dFull(rnd)
Signature: rnd:IRandomUniform -> V2d
UniformV2dFull(rnd, box)
Signature: (rnd:IRandomUniform * box:Box2d) -> V2d
UniformV2dFullClosed(rnd)
Signature: rnd:IRandomUniform -> V2d
UniformV2dFullClosed(rnd, box)
Signature: (rnd:IRandomUniform * box:Box2d) -> V2d
UniformV2dFullOpen(rnd)
Signature: rnd:IRandomUniform -> V2d
UniformV2dFullOpen(rnd, box)
Signature: (rnd:IRandomUniform * box:Box2d) -> V2d
UniformV2dOpen(rnd)
Signature: rnd:IRandomUniform -> V2d
UniformV2dOpen(rnd, box)
Signature: (rnd:IRandomUniform * box:Box2d) -> V2d
UniformV3d(rnd)
Signature: rnd:IRandomUniform -> V3d
UniformV3d(rnd, box)
Signature: (rnd:IRandomUniform * box:Box3d) -> V3d
UniformV3dClosed(rnd)
Signature: rnd:IRandomUniform -> V3d
UniformV3dClosed(rnd, box)
Signature: (rnd:IRandomUniform * box:Box3d) -> V3d
UniformV3dClosedSphere(rnd)
Signature: rnd:IRandomUniform -> V3d

Uniform vector in the closed unit sphere (i.e vectors to the surface of the sphere may be generated).

UniformV3dDirection(rnd)
Signature: rnd:IRandomUniform -> V3d

Returns a uniformly distributed vector (corresponds to a uniformly distributed point on the surface of the unit sphere). Note however, that the returned vector will never be equal to [0, 0, -1].

UniformV3dFull(rnd)
Signature: rnd:IRandomUniform -> V3d
UniformV3dFull(rnd, box)
Signature: (rnd:IRandomUniform * box:Box3d) -> V3d
UniformV3dFullClosed(rnd)
Signature: rnd:IRandomUniform -> V3d
UniformV3dFullClosed(rnd, box)
Signature: (rnd:IRandomUniform * box:Box3d) -> V3d
UniformV3dFullDirection(rnd)
Signature: rnd:IRandomUniform -> V3d

Returns a fully uniformly distributed vector (corresponds to a uniformly distributed point on the surface of the unit sphere). Note however, that the returned vector will never be equal to [0, 0, -1].

UniformV3dFullOpen(rnd)
Signature: rnd:IRandomUniform -> V3d
UniformV3dFullOpen(rnd, box)
Signature: (rnd:IRandomUniform * box:Box3d) -> V3d
UniformV3dOpen(rnd)
Signature: rnd:IRandomUniform -> V3d
UniformV3dOpen(rnd, box)
Signature: (rnd:IRandomUniform * box:Box3d) -> V3d
UniformV3dOpenSphere(rnd)
Signature: rnd:IRandomUniform -> V3d

Uniform vector inside the open unit sphere (i.e. no vector ends on the surface of the sphere).

Fork me on GitHub