-
Notifications
You must be signed in to change notification settings - Fork 102
Closed
Description
Description
Chart.Histogram seems to not accurately reflect the underlying data, unless I'm misunderstanding how things work.
Repro steps
Consider the code:
let rnd = System.Random()
let x =
[ for i = 0 to 1000000 do
yield rnd.NextDouble() ] //double range from 0 to 1
let histo1 = Chart.Histogram(X = x, NBinsX = 5)
histo1 |> Chart.show
This shows a histogram chart with a non-even distribution of what should be evenly distributed numbers (5 bins, each 0.2 in size, from 0 to 1). In fact, bin 0-0.2, and bin 0.8-1 show only 100k elements, whilst bins 0.2-0.4, 0.4-0.6, 0.6-0.8 show 200k elements - a 50% error.
Expected behavior
There should be an even distribution. This can be confirmed by running the following code after the above code:
let counts = List.groupBy (fun t ->
match t with
| x when x < 0.2 -> 1
| x when x < 0.4 -> 2
| x when x < 0.6 -> 3
| x when x < 0.8 -> 4
| _ -> 5) x
|> List.map (fun (group, x) -> x.Length)
printfn $"counts: {counts}"
(the counts are evenly distributed)
Related information
- Windows 10
- Master
- .NET 6, F# Interactive
Metadata
Metadata
Assignees
Labels
No labels