F64Table generates an table with a histogram of counts of values within given number of bins and min / max range. The table has columns: Value, Count if value is < min or > max it is ignored. The Value column represents the min value for each bin, with the max being the value of the next bin, or the
(dt *table.Table, vals []float64, nBins int, min, max float64)
| 42 | // The Value column represents the min value for each bin, with the max being |
| 43 | // the value of the next bin, or the max if at the end. |
| 44 | func F64Table(dt *table.Table, vals []float64, nBins int, min, max float64) { |
| 45 | dt.DeleteAll() |
| 46 | dt.AddFloat64Column("Value") |
| 47 | dt.AddFloat64Column("Count") |
| 48 | dt.SetNumRows(nBins) |
| 49 | ct := dt.Columns[1].(*tensor.Float64) |
| 50 | F64(&ct.Values, vals, nBins, min, max) |
| 51 | inc := (max - min) / float64(nBins) |
| 52 | vls := dt.Columns[0].(*tensor.Float64).Values |
| 53 | for i := 0; i < nBins; i++ { |
| 54 | vls[i] = math32.Truncate64(min+float64(i)*inc, 4) |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | ////////////////////////////////////////////////////// |
| 59 | // float32 |