rand

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2020 License: GPL-3.0 Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Rand

type Rand struct {
	*rand.Rand
	// contains filtered or unexported fields
}

* Wrapper for the rand.Rand struct. Applies scaling defined by a Config * struct.

func NoScale added in v0.1.0

func NoScale(s rand.Source) (r Rand)

Create a new random number generator with the default configuration.

func (Rand) Float32

func (r Rand) Float32() (f float32)

Get a random Float32.

func (Rand) Float64

func (r Rand) Float64() (f float64)

Get a random Float64.

func (Rand) Int

func (r Rand) Int() (i int)

Get a random Int.

type Scale

type Scale struct {
	Mean float64
	Std  float64
}

* Configuration for shifting the mean value and scaling the standard * deviation of random values.

func DefaultScale

func DefaultScale() (s Scale)

Returns a copy of the default configuration with zero mean and 1.0 standard deviation.

func (Scale) Float32

func (s Scale) Float32(f float32) (rf float32)

scale a float32 number

func (Scale) Float64

func (s Scale) Float64(f float64) (rf float64)

scale a float64 number

func (Scale) Int

func (s Scale) Int(i int) (ri int)

scale an integer number

func (Scale) New

func (sc Scale) New(s rand.Source) (r Rand)

Create a new Rand struct with configuration defined by Config.

type Scaler

type Scaler interface {
	Int(int) int
	Float32(float32) float32
	Float64(float64) float64
}

type Source

type Source rand.Source

type alias for the rand package's rand.Source type

func NewSource

func NewSource(seed int64) (s Source)

wrapper for the rand package NewSource function

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL