floatrange

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2018 License: MIT Imports: 3 Imported by: 42

Documentation

Overview

Package floatrange holds distributions that accept and return float64s

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Constant

type Constant float64

Constant is a range that represents some constant float

func (Constant) EnforceRange

func (c Constant) EnforceRange(float64) float64

EnforceRange returns the float behind the constant

func (Constant) InRange

func (c Constant) InRange(f float64) bool

InRange returns whether f == the float behind the constant

func (Constant) Mult

func (c Constant) Mult(f float64) Range

Mult scales c by f

func (Constant) Percentile

func (c Constant) Percentile(float64) float64

Percentile returns the float behind the constant

func (Constant) Poll

func (c Constant) Poll() float64

Poll returns the float behind the constant

type Infinite

type Infinite struct{}

Infinite is an immutable range that will always return math.MaxFloat64

func (Infinite) EnforceRange

func (i Infinite) EnforceRange(f float64) float64

EnforceRange returns math.MaxFloat64

func (Infinite) InRange

func (i Infinite) InRange(f float64) bool

InRange returns true if f is math.MaxFLoat64

func (Infinite) Mult

func (i Infinite) Mult(f float64) Range

Mult returns an infinite from an infinite.

func (Infinite) Percentile

func (i Infinite) Percentile(float64) float64

Percentile returns the float behind the constant

func (Infinite) Poll

func (i Infinite) Poll() float64

Poll returns MaxFloat64 on an infinite

type Linear

type Linear struct {
	Max, Min float64
	// contains filtered or unexported fields
}

Linear is a range from min to max

func (Linear) EnforceRange

func (lfr Linear) EnforceRange(f float64) float64

EnforceRange returns f, if InRange(f), or the closest value in the range to f.

func (Linear) InRange

func (lfr Linear) InRange(f float64) bool

InRange returns whether an input float could be returned by Poll()

func (Linear) Mult

func (lfr Linear) Mult(f float64) Range

Mult scales a Linear by f

func (Linear) Percentile

func (lfr Linear) Percentile(f float64) float64

Percentile returns the fth percentile value along this range

func (Linear) Poll

func (lfr Linear) Poll() float64

Poll on a linear float range returns a float at uniform distribution in lfr's range

type Range

type Range interface {
	Poll() float64
	Mult(f float64) Range
	InRange(f float64) bool
	EnforceRange(f float64) float64
	Percentile(f float64) float64
}

Range represents a range of floating point numbers

func NewConstant

func NewConstant(f float64) Range

NewConstant returns f wrapped in Constant

func NewInfinite

func NewInfinite() Range

NewInfinite returns an infinite.

func NewLinear

func NewLinear(min, max float64) Range

NewLinear returns a linear range from min to max

func NewSpread

func NewSpread(base, spread float64) Range

NewSpread returns a linear range from base-spread to base+spread

Jump to

Keyboard shortcuts

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