MCPcopy Create free account
hub / github.com/cogentcore/core / F64

Function F64

tensor/stats/histogram/histogram.go:19–37  ·  view source on GitHub ↗

F64 generates a histogram of counts of values within given number of bins and min / max range. hist vals is sized to nBins. if value is < min or > max it is ignored.

(hist *[]float64, vals []float64, nBins int, min, max float64)

Source from the content-addressed store, hash-verified

17// number of bins and min / max range. hist vals is sized to nBins.
18// if value is < min or > max it is ignored.
19func F64(hist *[]float64, vals []float64, nBins int, min, max float64) {
20 *hist = slicesx.SetLength(*hist, nBins)
21 h := *hist
22 // 0.1.2.3 = 3-0 = 4 bins
23 inc := (max - min) / float64(nBins)
24 for i := 0; i < nBins; i++ {
25 h[i] = 0
26 }
27 for _, v := range vals {
28 if v < min || v > max {
29 continue
30 }
31 bin := int((v - min) / inc)
32 if bin >= nBins {
33 bin = nBins - 1
34 }
35 h[bin] += 1
36 }
37}
38
39// F64Table generates an table with a histogram of counts of values within given
40// number of bins and min / max range. The table has columns: Value, Count

Callers 2

F64TableFunction · 0.70
TestHistogram64Function · 0.70

Calls 1

SetLengthFunction · 0.92

Tested by 1

TestHistogram64Function · 0.56