Documentation ¶
Overview ¶
Package rand implements the Borland C/C++ pseudo-random number generator algorithm [1] to generate random Complex128 numbers in the range (-2,-2i) to (2,2i).
[1]: https://en.wikipedia.org/wiki/Linear_congruential_generator#Parameters_in_common_use
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ComplexRNG ¶
type ComplexRNG struct {
// contains filtered or unexported fields
}
func NewComplexRNG ¶
func NewComplexRNG(seed int64) (r ComplexRNG, err error)
Function NewComplexRnd returns a new ComplexRNG with the seed set to seed. If seed is set to 0 NewComplexRNG will use GetSeed to set seed. Methods on NewComplexRndThis are NOT Thread Safe, initiate one ComplexRNG per goroutine.
func (*ComplexRNG) Complex128 ¶
func (rng *ComplexRNG) Complex128() complex128
Complex128 returns a pseudo-random complex128 where the imag and real part is in the range -2 to 2.
func (*ComplexRNG) ComplexRand ¶
func (rng *ComplexRNG) ComplexRand() complex128
ComplexRand returns a pseudo-random complex128 where the imag and real part is in the range -2 to 2. The random values are evenly distributed between all possible floats in the specified range, this makes it very lightly to get a very small number very close to 0 as the density of valid floats are much denser near 0. Eg. The probability of getting a real part that is over 1 or lower than -1 is about 0.1% and the probability of getting a real part in between 1.0e-150 and -1.0e-150 is about 50%.
type ComplexRNGts ¶
type ComplexRNGts struct {
// contains filtered or unexported fields
}
func NewComplexRNGts ¶
func NewComplexRNGts(seed int64) (r ComplexRNGts, err error)
Function NewComplexRndts returns a new ComplexRNG with the seed set to seed. If seed is set to 0 NewComplexRNGts will use GetSeed to set seed. All methods on NewComplexRndts have sacrificed speed for thread safety. Equivalent methods on NewComplexRNG are about 5X faster.
func (*ComplexRNGts) Complex128 ¶
func (rng *ComplexRNGts) Complex128() complex128
Complex128 returns a pseudo-random complex128 where the imag and real part is in the range -2 to 2.
func (*ComplexRNGts) ComplexRand ¶
func (rng *ComplexRNGts) ComplexRand() complex128
ComplexRand returns a pseudo-random complex128 where the imag and real part is in the range -2 to 2. The random values are evenly distributed between all possible floats in the specified range, this makes it very lightly to get a very small number very close to 0 as the density of valid floats are much denser near 0. Eg. The probability of getting a real part that is over 1 or lower than -1 is about 0.1% and the probability of getting a real part in between 1.0e-150 and -1.0e-150 is about 50%.