Documentation ¶
Index ¶
- Constants
- func ConvertRTPFix(value []int64) [NMaxHit]int64
- func GenRandArray(weightArray []int32, arraySizze int32) uint32
- func GetRandom(maxN int32) int32
- func Lottery[T NonNegative_Integer](values []T) int
- func OpenPoint(calcWeight [NMaxHit][2]int64) int
- func Shuffle[T NonNegative_Integer](nums []T) []T
- func Uint32() uint32
- func Uint32n(maxN uint32) uint32
- type Negative_Number
- type NonNegative_Integer
- type NonNegative_Number
- type RNG
- type Rand
- func (r *Rand) ExpFloat64() float64
- func (r *Rand) FlipCoin(p float64) bool
- func (r *Rand) Float32() float32
- func (r *Rand) Float32Shuffle(values []float32)
- func (r *Rand) Float32r(low, high float32) float32
- func (r *Rand) Float32s(values []float32, low, high float32)
- func (r *Rand) Float64() float64
- func (r *Rand) Float64Shuffle(values []float64)
- func (r *Rand) Float64r(low, high float64) float64
- func (r *Rand) Float64s(values []float64, low, high float64)
- func (r *Rand) Int() int
- func (r *Rand) Int31() int32
- func (r *Rand) Int31Shuffle(values []int32)
- func (r *Rand) Int31n(n int32) int32
- func (r *Rand) Int31r(low, high int32) int32
- func (r *Rand) Int31s(values []int32, low, high int32)
- func (r *Rand) Int63() int64
- func (r *Rand) Int63Shuffle(values []int64)
- func (r *Rand) Int63n(n int64) int64
- func (r *Rand) Int63r(low, high int64) int64
- func (r *Rand) Int63s(values []int64, low, high int64)
- func (r *Rand) IntShuffle(values []int)
- func (r *Rand) Intn(n int) int
- func (r *Rand) Intr(low, high int) int
- func (r *Rand) Ints(values []int, low, high int)
- func (r *Rand) NormFloat64() float64
- func (r *Rand) Perm(n int) []int
- func (r *Rand) Read(p []byte) (n int, err error)
- func (r *Rand) Seed(seed int64)
- func (r *Rand) Shuffle(n int, swap func(i, j int))
- func (r *Rand) Uint32() uint32
- func (r *Rand) Uint32Shuffle(values []uint32)
- func (r *Rand) Uint32r(low, high uint32) uint32
- func (r *Rand) Uint32s(values []uint32, low, high uint32)
- func (r *Rand) Uint64() uint64
- func (r *Rand) Uint64Shuffle(values []uint64)
- func (r *Rand) Uint64r(low, high uint64) uint64
- func (r *Rand) Uint64s(values []uint64, low, high uint64)
Constants ¶
const ( NMaxHit = 5 NEnlarge = 30000 BaseEnlarge = 100 )
Variables ¶
This section is empty.
Functions ¶
func ConvertRTPFix ¶ added in v0.0.9
func GenRandArray ¶
GenRandArray - safe
Types ¶
type Negative_Number ¶ added in v0.0.17
type NonNegative_Integer ¶ added in v0.0.17
type NonNegative_Number ¶ added in v0.0.17
type NonNegative_Number interface { ~float32 | ~float64 | ~complex64 | ~complex128 }
type RNG ¶
type RNG struct {
// contains filtered or unexported fields
}
RNG is a pseudorandom number generator.
It is unsafe to call RNG methods from concurrent goroutines.
func (*RNG) GenRandArray ¶
GenRandArray -
type Rand ¶
type Rand struct {
// contains filtered or unexported fields
}
func New ¶
New returns a new gosfmt Rand that uses random values from src to generate other random values.
func (*Rand) ExpFloat64 ¶
ExpFloat64 returns an exponentially distributed float64 in the range (0, +math.MaxFloat64] with an exponential distribution whose rate parameter (lambda) is 1 and whose mean is 1/lambda (1) from the default Source. To produce a distribution with a different rate parameter, callers can adjust the output using:
sample = ExpFloat64() / desiredRateParameter
func (*Rand) Float32Shuffle ¶
Float32Shuffle shuffles a slice of float point numbers
func (*Rand) Float32r ¶
Float32r generates a pseudo random real number between low and high; i.e. in [low, right)
Input: low -- lower limit (closed) high -- upper limit (open) Output: random float32
func (*Rand) Float32s ¶
Float32s generates pseudo random real numbers between low and high; i.e. in [low, right)
Input: low -- lower limit (closed) high -- upper limit (open) Output: values -- slice to be filled with len(values) numbers
func (*Rand) Float64Shuffle ¶
Float64Shuffle shuffles a slice of float point numbers
func (*Rand) Float64r ¶
Float64r generates a pseudo random real number between low and high; i.e. in [low, right)
Input: low -- lower limit (closed) high -- upper limit (open) Output: random float64
func (*Rand) Float64s ¶
Float64s generates pseudo random real numbers between low and high; i.e. in [low, right)
Input: low -- lower limit (closed) high -- upper limit (open) Output: values -- slice to be filled with len(values) numbers
func (*Rand) Int31Shuffle ¶
Int31Shuffle - shuffles a slice of integers
func (*Rand) Int31n ¶
Int31n returns, as an int32, a non-negative pseudo-random number in [0,n). It panics if n <= 0.
func (*Rand) Int31r ¶
Int31r is int range generates pseudo random int32 between low and high.
Input: low -- lower limit high -- upper limit Output: random int32
func (*Rand) Int31s ¶
Int31s generates pseudo random integers between low and high.
Input: low -- lower limit high -- upper limit Output: values -- slice to be filled with len(values) numbers
func (*Rand) Int63Shuffle ¶
Int63Shuffle - shuffles a slice of integers
func (*Rand) Int63n ¶
Int63n returns, as an int64, a non-negative pseudo-random number in [0,n). It panics if n <= 0.
func (*Rand) Int63r ¶
Int63r generates pseudo random int64 between low and high.
Input: low -- lower limit high -- upper limit Output: random int64
func (*Rand) Int63s ¶
Int63s generates pseudo random integers between low and high.
Input: low -- lower limit high -- upper limit Output: values -- slice to be filled with len(values) numbers
func (*Rand) IntShuffle ¶
IntShuffle shuffles a slice of integers
func (*Rand) Intn ¶
Intn returns, as an int, a non-negative pseudo-random number in [0,n). It panics if n <= 0.
func (*Rand) Intr ¶
Intr is int range generates pseudo random integer between low and high.
Input: low -- lower limit high -- upper limit Output: random integer
func (*Rand) Ints ¶
Ints generates pseudo random integers between low and high.
Input: low -- lower limit high -- upper limit Output: values -- slice to be filled with len(values) numbers
func (*Rand) NormFloat64 ¶
NormFloat64 returns a normally distributed float64 in the range [-math.MaxFloat64, +math.MaxFloat64] with standard normal distribution (mean = 0, stddev = 1) from the default Source. To produce a different normal distribution, callers can adjust the output using:
sample = NormFloat64() * desiredStdDev + desiredMean
func (*Rand) Perm ¶
Perm returns, as a slice of n ints, a pseudo-random permutation of the integers [0,n).
func (*Rand) Read ¶
Read generates len(p) random bytes and writes them into p. It always returns len(p) and a nil error. Read should not be called concurrently with any other Rand method.
func (*Rand) Seed ¶
Seed uses the provided seed value to initialize the generator to a deterministic state. Seed should not be called concurrently with any other Rand method.
func (*Rand) Shuffle ¶
Shuffle pseudo-randomizes the order of elements. n is the number of elements. Shuffle panics if n < 0. swap swaps the elements with indexes i and j.
func (*Rand) Uint32Shuffle ¶
Uint32Shuffle shuffles a slice of integers
func (*Rand) Uint32r ¶
Uint32 is int range generates pseudo random uint32 between low and high.
Input: low -- lower limit high -- upper limit Output: random uint32
func (*Rand) Uint32s ¶
Uint32s generates pseudo random integers between low and high.
Input: low -- lower limit high -- upper limit Output: values -- slice to be filled with len(values) numbers
func (*Rand) Uint64Shuffle ¶
Uint64Shuffle - shuffles a slice of integers