Documentation ¶
Overview ¶
Package minmax provides a struct that holds Min and Max values.
Index ¶
- Constants
- func NiceRoundNumber(x float64, below bool) float64
- type AvgMax32
- func (am *AvgMax32) CalcAvg()
- func (am *AvgMax32) CopyFrom(oth *AvgMax32)
- func (am *AvgMax32) Init()
- func (am *AvgMax32) String() string
- func (am *AvgMax32) UpdateFrom(oth *AvgMax32)
- func (am *AvgMax32) UpdateFromOther(oSum, oMax float32, oN, oMaxIndex int32)
- func (am *AvgMax32) UpdateValue(val float32, idx int32)
- type AvgMax64
- type F32
- func (mr *F32) ClipNormValue(val float32) float32
- func (mr *F32) ClipValue(val float32) float32
- func (mr *F32) FitInRange(oth F32) bool
- func (mr *F32) FitValInRange(val float32) bool
- func (mr *F32) InRange(val float32) bool
- func (mr *F32) IsHigh(val float32) bool
- func (mr *F32) IsLow(val float32) bool
- func (mr *F32) IsValid() bool
- func (mr *F32) Midpoint() float32
- func (mr *F32) NormValue(val float32) float32
- func (mr *F32) ProjValue(val float32) float32
- func (mr *F32) Range() float32
- func (mr *F32) Scale() float32
- func (mr *F32) Set(mn, mx float32)
- func (mr *F32) SetInfinity()
- func (mr *F32) String() string
- type F64
- func (mr *F64) ClipNormValue(val float64) float64
- func (mr *F64) ClipValue(val float64) float64
- func (mr *F64) FitInRange(oth F64) bool
- func (mr *F64) FitValInRange(val float64) bool
- func (mr *F64) InRange(val float64) bool
- func (mr *F64) IsHigh(val float64) bool
- func (mr *F64) IsLow(val float64) bool
- func (mr *F64) IsValid() bool
- func (mr *F64) Midpoint() float64
- func (mr *F64) NormValue(val float64) float64
- func (mr *F64) ProjValue(val float64) float64
- func (mr *F64) Range() float64
- func (mr *F64) Scale() float64
- func (mr *F64) Set(mn, mx float64)
- func (mr *F64) SetInfinity()
- type Int
- func (mr *Int) ClipNormValue(val int) float32
- func (mr *Int) ClipValue(val int) int
- func (mr *Int) FitInRange(oth Int) bool
- func (mr *Int) FitValInRange(val int) bool
- func (mr *Int) InRange(val int) bool
- func (mr *Int) IsHigh(val int) bool
- func (mr *Int) IsLow(val int) bool
- func (mr *Int) IsValid() bool
- func (mr *Int) Midpoint() float32
- func (mr *Int) NormValue(val int) float32
- func (mr *Int) ProjValue(val float32) float32
- func (mr *Int) Range() int
- func (mr *Int) Scale() float32
- func (mr *Int) Set(mn, mx int)
- func (mr *Int) SetInfinity()
- type Range32
- type Range64
Constants ¶
const ( MaxFloat32 float32 = 3.402823466e+38 MinFloat32 float32 = 1.175494351e-38 )
const ( MaxFloat64 float64 = 1.7976931348623158e+308 MinFloat64 float64 = 2.2250738585072014e-308 )
Variables ¶
This section is empty.
Functions ¶
func NiceRoundNumber ¶
NiceRoundNumber returns the closest nice round number either above or below the given number, based on the observation that numbers 1, 2, 5 at any power are "nice". This is used for choosing graph labels, and auto-scaling ranges to contain a given value. if below == true then returned number is strictly less than given number otherwise it is strictly larger.
Types ¶
type AvgMax32 ¶
type AvgMax32 struct { Avg float32 Max float32 // sum for computing average Sum float32 // index of max item MaxIndex int32 // number of items in sum N int32 // contains filtered or unexported fields }
AvgMax holds average and max statistics
func (*AvgMax32) CalcAvg ¶
func (am *AvgMax32) CalcAvg()
CalcAvg computes the average given the current Sum and N values
func (*AvgMax32) UpdateFrom ¶
UpdateFrom updates these values from other AvgMax32 values
func (*AvgMax32) UpdateFromOther ¶
UpdateFromOther updates these values from other AvgMax32 values
func (*AvgMax32) UpdateValue ¶
UpdateVal updates stats from given value
type AvgMax64 ¶
type AvgMax64 struct { Avg float64 Max float64 // sum for computing average Sum float64 // index of max item MaxIndex int32 // number of items in sum N int32 }
AvgMax holds average and max statistics
func (*AvgMax64) CalcAvg ¶
func (am *AvgMax64) CalcAvg()
CalcAvg computes the average given the current Sum and N values
func (*AvgMax64) UpdateFrom ¶
UpdateFrom updates these values from other AvgMax64
func (*AvgMax64) UpdateValue ¶
UpdateVal updates stats from given value
type F32 ¶
F32 represents a min / max range for float32 values. Supports clipping, renormalizing, etc
func (*F32) ClipNormValue ¶
ClipNormVal clips then normalizes given value within 0-1 Note: a NaN will remain as a NaN
func (*F32) ClipValue ¶
ClipVal clips given value within Min / Max range Note: a NaN will remain as a NaN
func (*F32) FitInRange ¶
FitInRange adjusts our Min, Max to fit within those of other F32 returns true if we had to adjust to fit.
func (*F32) FitValInRange ¶
FitValInRange adjusts our Min, Max to fit given value within Min, Max range returns true if we had to adjust to fit.
func (*F32) NormValue ¶
NormVal normalizes value to 0-1 unit range relative to current Min / Max range Clips the value within Min-Max range first.
func (*F32) ProjValue ¶
ProjVal projects a 0-1 normalized unit value into current Min / Max range (inverse of NormVal)
func (*F32) SetInfinity ¶
func (mr *F32) SetInfinity()
SetInfinity sets the Min to +MaxFloat, Max to -MaxFloat -- suitable for iteratively calling Fit*InRange
type F64 ¶
F64 represents a min / max range for float64 values. Supports clipping, renormalizing, etc
func (*F64) ClipNormValue ¶
ClipNormVal clips then normalizes given value within 0-1 Note: a NaN will remain as a NaN
func (*F64) ClipValue ¶
ClipVal clips given value within Min / Max range Note: a NaN will remain as a NaN
func (*F64) FitInRange ¶
FitInRange adjusts our Min, Max to fit within those of other F64 returns true if we had to adjust to fit.
func (*F64) FitValInRange ¶
FitValInRange adjusts our Min, Max to fit given value within Min, Max range returns true if we had to adjust to fit.
func (*F64) NormValue ¶
NormVal normalizes value to 0-1 unit range relative to current Min / Max range Clips the value within Min-Max range first.
func (*F64) ProjValue ¶
ProjVal projects a 0-1 normalized unit value into current Min / Max range (inverse of NormVal)
func (*F64) SetInfinity ¶
func (mr *F64) SetInfinity()
SetInfinity sets the Min to +MaxFloat, Max to -MaxFloat -- suitable for iteratively calling Fit*InRange
type Int ¶
Int represents a min / max range for int values. Supports clipping, renormalizing, etc
func (*Int) ClipNormValue ¶
ClipNormVal clips then normalizes given value within 0-1
func (*Int) FitInRange ¶
FitInRange adjusts our Min, Max to fit within those of other Int returns true if we had to adjust to fit.
func (*Int) FitValInRange ¶
FitValInRange adjusts our Min, Max to fit given value within Min, Max range returns true if we had to adjust to fit.
func (*Int) NormValue ¶
NormVal normalizes value to 0-1 unit range relative to current Min / Max range Clips the value within Min-Max range first.
func (*Int) ProjValue ¶
ProjVal projects a 0-1 normalized unit value into current Min / Max range (inverse of NormVal)
func (*Int) SetInfinity ¶
func (mr *Int) SetInfinity()
SetInfinity sets the Min to +MaxFloat, Max to -MaxFloat -- suitable for iteratively calling Fit*InRange
type Range32 ¶
type Range32 struct { // Min and Max range values F32 // fix the minimum end of the range FixMin bool // fix the maximum end of the range FixMax bool }
Range32 represents a range of values for plotting, where the min or max can optionally be fixed