Maths.PseudoRandom

public static class Maths.PseudoRandom
Central utilities for creating random engines and random collections.

Methods

CirclesOnDiscFibonacci

#
Create a circle packing on the interior of a disc.
public static Circle[] CirclesOnDiscFibonacci(
disc,
Disc to populate.
count,
Number of circles.
token
Cancellation token.
)

CirclesOnDiscHexagonal

#
Create a hexagonal pattern of circles with radius 1 around the origin.
public static Circle[] CirclesOnDiscHexagonal(
disc,
count,
token
)

CirclesOnDiscOctagonal

#
Create an octogonal pattern of circles with varying radii around the origin.
public static Circle[] CirclesOnDiscOctagonal(
disc,
count,
token
)

CirclesOnDiscSquare

#
Create a hexagonal pattern of circles with radius 1 around the origin.
public static Circle[] CirclesOnDiscSquare(
disc,
count,
token
)

CirclesOnDiscStacked

#
Create a circle packing on the interior of a disc.
public static Circle[] CirclesOnDiscStacked(
disc,
Disc to populate.
count,
Number of circles.
token
Cancellation token.
)

CirclesOnSphericalPoints

#
Place circles on point coordinates assumed to lie on a sphere with origin at (0,0,0).
public static Circle[] CirclesOnSphericalPoints(
x,
Point X coordinates.
y,
Point Y coordinates.
z,
Point A coordinates.
token,
Cancellation token.
initialRadius = Infinity
Initial radius to beat.
)
Array of non-intersecting circles.

CreateRandomEngine

#
Create a new instance of a specific generator.
public static Random CreateRandomEngine(
algorithm,
Engine to use. The System engine cannot be instantiated this way.
seed
Seed value.
)
Non-threadsafe random number generator.

DilatePointsWithinBox

#
Dilates the specified array of 3D points outward from a given origin so that all points remain within the defined box dimensions, and retains only the specified number of points closest to the origin after dilation.
public static void DilatePointsWithinBox(
ref Point3d[]
points,
A reference to an array of Point3d structures representing the points to be dilated. The array is modified in place to contain only the closest points after dilation.
count,
The number of points to retain after dilation. Must be less than or equal to the length of the points array.
length,
An Interval that defines the allowable range for the x-coordinates of the box within which the points will be dilated.
width,
An Interval that defines the allowable range for the y-coordinates of the box within which the points will be dilated.
height,
An Interval that defines the allowable range for the z-coordinates of the box within which the points will be dilated.
origin
The origin point from which the dilation is performed. Points are scaled outward from this location.
)
Remarks: If the number of points in the array is less than or equal to the specified count, the method does not modify the array. The order of points in the resulting array may differ from the original order.

DilatePointsWithinCircle

#
Spatially inflate an array of points until all but N are outside a circle.
public static void DilatePointsWithinCircle(
ref Point2d[]
points,
Points to scale.
count,
Number of points to retain.
centre,
Centre of circle.
radius
Radius of circle.
)

DilatePointsWithinCircle

#
Spatially inflate an array of points until all but N are outside a circle.
public static void DilatePointsWithinCircle(
ref Point3d[]
points,
Points to scale.
count,
Number of points to retain.
centre,
Centre of circle.
radius
Radius of circle.
)

DilatePointsWithinRectangle

#
Spatially inflate an array of points until all but N are outside an axis aligned rectangle.
public static void DilatePointsWithinRectangle(
ref Point2d[]
points,
Points to scale.
count,
Number of points to retain.
width,
Width of axis aligned rectangle.
height,
Height of axis aligned rectangle.
origin
Scaling origin point. If the origin does not lie within the rectangle, the results cannot be trusted.
)

DilatePointsWithinRectangle

#
Spatially inflate an array of points until all but N are outside an axis aligned rectangle.
public static void DilatePointsWithinRectangle(
ref Point2d[]
points,
Points to scale.
count,
Number of points to retain.
width,
Width of axis aligned rectangle.
height
Height of axis aligned rectangle.
)

DilatePointsWithinRectangle

#
Spatially inflate an array of points until all but N are outside an axis aligned rectangle.
public static void DilatePointsWithinRectangle(
ref Point3d[]
points,
Points to scale.
count,
Number of points to retain.
width,
Width of axis aligned rectangle.
height,
Height of axis aligned rectangle.
origin
Scaling origin point. If the origin does not lie within the rectangle, the results cannot be trusted.
)

DilatePointsWithinSphere

#
Dilates a specified number of points within a defined spherical region, scaling their positions relative to a center point.
public static void DilatePointsWithinSphere(
ref Point3d[]
points,
An array of Point3d structures representing the points to be dilated. The method modifies this array to contain only the dilated points.
count,
The number of points to retain after dilation. Must be less than or equal to the length of the points array.
centre,
The center point of the sphere around which the dilation occurs.
radius
The radius of the sphere within which points will be dilated. Must be a positive value.
)
Remarks: The method performs a partial sort to efficiently determine which points are closest to the center before applying the dilation. It modifies the input array to contain only the dilated points.

FibonacciHalfSphere

#
Generates the coordinates of a Fibonacci point sampling on the upper half of the unit sphere.
public static void FibonacciHalfSphere(
count,
Number of samples.
out double[]
x,
Sample x coordinates.
out double[]
y,
Sample y coordinates.
out double[]
z
Sample z coordinates.
)

FibonacciUnitDisc

#
Generates the coordinates of a Fibonacci point sampling on the unit disc.
public static void FibonacciUnitDisc(
count,
Number of samples.
out double[]
x,
Sample x coordinates.
out double[]
y
Sample y coordinates.
)

FibonacciUnitSphere

#
Generates the coordinates of a Fibonacci point sampling on the unit sphere.
public static void FibonacciUnitSphere(
count,
Number of samples.
out double[]
x,
Sample x coordinates.
out double[]
y,
Sample y coordinates.
out double[]
z
Sample z coordinates.
)

FibonacciUnitSquare

#
Generates the coordinates of a Fibonacci point sampling on the unit square.
public static void FibonacciUnitSquare(
count,
Number of samples.
out double[]
x,
Sample x coordinates.
out double[]
y
Sample y coordinates.
)

FormatEngineAlgorithm

#
Create a human-centric string which describes a certain random algorithm.
public static string FormatEngineAlgorithm(
algorithm
)

ParseEngineAlgorithm

#
Try and parse a random engine by name.
public static bool ParseEngineAlgorithm(
text,
out Engine
engine
)

Poisson2D

#
Create a two-dimensional Poisson sampling with a variable separation radius. This algorithm relies on slow spatial lookup of neighbouring coordinates since no assumptions can be made regarding the minimum allowed spacing across the entire field. As a result this method probably will not yield the same distribution as the Poisson2D method which takes a constant radius value.
public static Point2d[] Poisson2D(
engine,
Random engine.
setup,
Properties for poisson distribution.
density
Minimum allowed distance between samples. This function will be sampled and obeyed locally. It is entirely possible that a point pair exists in the final distribution closer together than one of the points local radius constraint.
)
An array of two-dimensional coordinates within the (min, max) region.

Poisson2D

#
Create a two-dimensional Poisson sampling with a constant separation radius.
public static Point2d[] Poisson2D(
engine,
Random engine.
setup
Properties for poisson distribution.
)
An array of two-dimensional coordinates within the (min, max) region, no two of which are closer than the specified radius.

Populate1D

#
Randomly populate a one-dimensional interval. This method works by randomly dividing the longest remaining interval into two until a fixed number of values has been found.
public static double[] Populate1D(
engine,
Random engine to use.
min,
Lower limit.
max,
Upper limit.
count,
Number of values to create.
spread
Spreading factor (0, 1). Zero equals splitting exactly in the middle, one equals splitting within the full domain.
)
An array of numbers between min and max.

RandomIntegers

#
Generate an enumeration of random, non-negative integers.
public static IEnumerable<int> RandomIntegers(
engine,
Engine to use.
seed,
Initial seed value.
lowerInclusive,
Lower inclusive limit.
upperExclusive
Upper exclusive limit.
)
Infinite collection of random integers.

RandomIntegers

#
Generate an enumeration of random, non-negative integers.
public static IEnumerable<int> RandomIntegers(
engine,
Engine to use.
seed
Initial seed value.
)
Infinite collection of random integers.

RandomIntegers

#
Generate an enumeration of random, non-negative integers.
public static int[] RandomIntegers(
engine,
Engine to use.
seed,
Initial seed value.
count,
Amount of random numbers to generate.
lowerInclusive,
Lower inclusive limit.
upperExclusive
Upper exclusive limit.
)
Infinite collection of random integers.

RandomIntegers

#
Generate an enumeration of random, non-negative integers.
public static int[] RandomIntegers(
engine,
Engine to use.
seed,
Initial seed value.
count
Amount of random numbers to generate.
)
Infinite collection of random integers.

RandomNumbers

#
Generate an enumeration of random, non-negative integers.
public static double[] RandomNumbers(
engine,
Engine to use.
seed,
Initial seed value.
count,
Amount of random numbers to generate.
lower,
Lower limit.
upper
Upper limit.
)
Infinite collection of random integers.

RandomNumbers

#
Generate an enumeration of random, non-negative integers.
public static double[] RandomNumbers(
engine,
Engine to use.
seed,
Initial seed value.
count
Amount of random numbers to generate.
)
Infinite collection of random integers.

RandomNumbers

#
Generate an enumeration of random, non-negative integers.
public static IEnumerable<double> RandomNumbers(
engine,
Engine to use.
seed,
Initial seed value.
lower,
Lower limit.
upper
Upper limit.
)
Infinite collection of random integers.

RandomNumbers

#
Generate an enumeration of random, non-negative integers.
public static IEnumerable<double> RandomNumbers(
engine,
Engine to use.
seed
Initial seed value.
)
Infinite collection of random integers.

VanDerCorputUnitCube

#
Create a Van Der Corput distribution within the unit cube.
public static void VanDerCorputUnitCube(
count,
out double[]
x,
out double[]
y,
out double[]
z
)

VanDerCorputUnitSquare

#
Generates the coordinates of a van der Corput Quasi random point set on the unit square. The distances between adjacent points are more similar than using a strict pseudo-random distribution, not quite as good as a Poisson distribution but very fast. The x coordinates increase steadily from zero to (n-1)/n, whereas the associated y coordinates are spread out using a quasi-mote-carlo pattern.
public static void VanDerCorputUnitSquare(
count,
Number of points.
out double[]
x,
X coordinates of random points.
out double[]
y
Y coordinates of random points.
)