module KDE:sig
..end
type
bandwidth =
| |
Silverman |
(* | Use rule-of-thumb for choosing the bandwidth.
It defaults to
0.9 * min(SD, IQR / 1.34) * n^-0.2 . | *) |
| |
Scott |
(* | Same as Silverman , but with a factor, equal to
1.06 . | *) |
type
kernel =
| |
Gaussian |
val estimate_pdf : ?kernel:kernel ->
?bandwidth:bandwidth ->
?n_points:int -> float array -> float array * float array
open Pareto
let open Distributions.Normal in
let vs = sample ~size:100 standard in
let (points, pdf) = Sample.KDE.estimate_pdf ~points:10 vs in begin
(* Output an ASCII density plot. *)
Array.iteri (fun i d ->
let count = int_of_float (d *. 20.) in
printf "%9.5f " points.(i);
for i = 0 to count do
print_char (if i = count then '.' else ' ');
done;
print_newline ();
) pdf
end