Documentation ¶
Overview ¶
Package minmax provides basic minimum / maximum values for float32 and float64
Index ¶
- func NiceRoundNumber(x float64, below bool) float64
- type AvgMax32
- type AvgMax64
- type F32
- func (mr *F32) ClipNormVal(val float32) float32
- func (mr *F32) ClipVal(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) NormVal(val float32) float32
- func (mr *F32) ProjVal(val float32) float32
- func (mr *F32) Range() float32
- func (mr *F32) Scale() float32
- func (mr *F32) Set(min, max float32)
- func (mr *F32) SetInfinity()
- type F64
- func (mr *F64) ClipNormVal(val float64) float64
- func (mr *F64) ClipVal(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) NormVal(val float64) float64
- func (mr *F64) ProjVal(val float64) float64
- func (mr *F64) Range() float64
- func (mr *F64) Scale() float64
- func (mr *F64) Set(min, max float64)
- func (mr *F64) SetInfinity()
- type Int
- func (mr *Int) ClipNormVal(val int) float32
- func (mr *Int) ClipVal(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) NormVal(val int) float32
- func (mr *Int) ProjVal(val float32) float32
- func (mr *Int) Range() int
- func (mr *Int) Scale() float32
- func (mr *Int) Set(min, max int)
- func (mr *Int) SetInfinity()
- type Range32
- type Range64
Constants ¶
This section is empty.
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 MaxIdx int `desc:"index of max item"` Sum float32 `desc:"sum for computing average"` N int `desc:"number of items in sum"` }
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
type AvgMax64 ¶
type AvgMax64 struct { Avg float64 Max float64 MaxIdx int `desc:"index of max item"` Sum float64 `desc:"sum for computing average"` N int `desc:"number of items in sum"` }
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
type F32 ¶
F32 represents a min / max range for float32 values. Supports clipping, renormalizing, etc
func (*F32) ClipNormVal ¶ added in v1.0.0
ClipNormVal clips then normalizes given value within 0-1 Note: a NaN will remain as a NaN
func (*F32) ClipVal ¶
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) NormVal ¶
NormVal normalizes value to 0-1 unit range relative to current Min / Max range Clips the value within Min-Max range first.
func (*F32) ProjVal ¶
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) ClipNormVal ¶ added in v1.0.0
ClipNormVal clips then normalizes given value within 0-1 Note: a NaN will remain as a NaN
func (*F64) ClipVal ¶
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) NormVal ¶
NormVal normalizes value to 0-1 unit range relative to current Min / Max range Clips the value within Min-Max range first.
func (*F64) ProjVal ¶
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 ¶ added in v1.0.1
Int represents a min / max range for int values. Supports clipping, renormalizing, etc
func (*Int) ClipNormVal ¶ added in v1.0.1
ClipNormVal clips then normalizes given value within 0-1
func (*Int) FitInRange ¶ added in v1.0.1
FitInRange adjusts our Min, Max to fit within those of other Int returns true if we had to adjust to fit.
func (*Int) FitValInRange ¶ added in v1.0.1
FitValInRange adjusts our Min, Max to fit given value within Min, Max range returns true if we had to adjust to fit.
func (*Int) InRange ¶ added in v1.0.1
InRange tests whether value is within the range (>= Min and <= Max)
func (*Int) NormVal ¶ added in v1.0.1
NormVal normalizes value to 0-1 unit range relative to current Min / Max range Clips the value within Min-Max range first.
func (*Int) ProjVal ¶ added in v1.0.1
ProjVal projects a 0-1 normalized unit value into current Min / Max range (inverse of NormVal)
func (*Int) SetInfinity ¶ added in v1.0.1
func (mr *Int) SetInfinity()
SetInfinity sets the Min to +MaxFloat, Max to -MaxFloat -- suitable for iteratively calling Fit*InRange
type Range32 ¶
type Range32 struct { F32 `desc:"Min and Max range values"` FixMin bool `desc:"fix the minimum end of the range"` FixMax bool `desc:"fix the maximum end of the range"` }
Range32 represents a range of values for plotting, where the min or max can optionally be fixed