Documentation
¶
Overview ¶
Package random contains various methods for creating random values.
Index ¶
- func Angle() float64
- func Around(val, amt float64) float64
- func Boolean() bool
- func Float() float64
- func FloatArray(size int, min, max float64) []float64
- func FloatRange(min float64, max float64) float64
- func GaussRange(min, max float64) float64
- func Int() int
- func IntArray(size int, min, max int) []int
- func IntRange(min int, max int) int
- func Norm(mean, std float64) float64
- func Power(min, max, power float64) float64
- func RandSeed() int64
- func Seed(seed int64)
- func String(length int) string
- func StringAlpha(length int) string
- func StringLower(length int) string
- func StringUpper(length int) string
- func WeightedBool(weight float64) bool
- type Random
- func (r *Random) Angle() float64
- func (r *Random) Boolean() bool
- func (r Random) Complex() complex128
- func (r Random) ComplexRange(realMin, realMax, imagMin, imagMax float64) complex128
- func (r *Random) Float() float64
- func (r *Random) FloatArray(size int, min, max float64) []float64
- func (r *Random) FloatRange(min float64, max float64) float64
- func (r *Random) GaussRange(min, max float64) float64
- func (r *Random) Int() int
- func (r *Random) IntArray(size int, min, max int) []int
- func (r *Random) IntRange(min int, max int) int
- func (r *Random) Norm(mean, std float64) float64
- func (r *Random) Power(min, max, power float64) float64
- func (r *Random) RandSeed() int64
- func (r *Random) Seed(seed int64)
- func (r *Random) String(length int) string
- func (r *Random) StringAlpha(length int) string
- func (r *Random) StringFrom(length int, chars string) string
- func (r *Random) StringLower(length int) string
- func (r *Random) StringUpper(length int) string
- func (r *Random) WeightedBool(weight float64) bool
- func (r Random) WeightedIndex(weights []float64) int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Around ¶
Around returns a random float around a given number. val is the center. amt is how much on either side the result will vary.
func FloatArray ¶
FloatArray returns an array of a given size filled with random floats from min to max.
func FloatRange ¶
FloatRange returns a random float from min to max.
func GaussRange ¶
GaussRange returns a random number within a normal distribution (mostly) within a min/max range.
func Norm ¶
Norm returns a random number within a normal distribution with the given mean and standard deviation.
func StringAlpha ¶
StringAlpha returns a random string of letters.
func StringLower ¶
StringLower returns a random lower case string.
func StringUpper ¶
StringUpper returns a random upper case string.
Types ¶
type Random ¶
type Random struct {
// contains filtered or unexported fields
}
Random represents a single unique PRNG
func (Random) Complex ¶
func (r Random) Complex() complex128
Complex returns a random complex number from -1 + -1i to 1 + 1i
func (Random) ComplexRange ¶
func (r Random) ComplexRange(realMin, realMax, imagMin, imagMax float64) complex128
ComplexRange returns a random complex number in the given ranges.
func (*Random) FloatArray ¶
FloatArray returns an array of a given size filled with random floats from min to max.
func (*Random) FloatRange ¶
FloatRange returns a random float from min to max.
func (*Random) GaussRange ¶
GaussRange returns a random number within a normal distribution (mostly) within a min/max range.
func (*Random) IntArray ¶
IntArray returns an array of a given size filled with random int from min to max.
func (*Random) Norm ¶
Norm returns a random number within a normal distribution with the given mean and standard deviation.
func (*Random) StringAlpha ¶
StringAlpha returns a random string of letters.
func (*Random) StringFrom ¶
StringFrom returns a random string of characters from the source string.
func (*Random) StringLower ¶
StringLower returns a random lower case string.
func (*Random) StringUpper ¶
StringUpper returns a random upper case string.
func (*Random) WeightedBool ¶
WeightedBool returns a weighted boolean.
func (Random) WeightedIndex ¶
WeightedIndex returns a random int based on an array of weights.