module KDE: sig .. end
type bandwidth =
Bandwidth selection rules.
type kernel =
val estimate_pdf : ?kernel:kernel ->
?bandwidth:bandwidth ->
?n_points:int -> float array -> float array * float array
O(n * points) Simple kernel density estimator. Returns an array
of uniformly spaced points from the sample range at which the
density function was estimated, and the estimates at these points.
Example
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
References
- B.W. Silverman, "Density Estimation for Statistics and Data
Analysis", Vol. 26, Monographs on Statistics and Applied
Probability, Chapman and Hall, London, 1986.