Skip to content

Commit

Permalink
Added a usage example for 'Sample.KDE'
Browse files Browse the repository at this point in the history
  • Loading branch information
superbobry committed May 7, 2013
1 parent bdec185 commit 56799cc
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ setup.*
*.native
*.byte
*.docdir
*.ba*
8 changes: 7 additions & 1 deletion myocamlbuild.ml
Original file line number Diff line number Diff line change
Expand Up @@ -581,4 +581,10 @@ let dispatch_default = MyOCamlbuildBase.dispatch_default package_default;;

# 583 "myocamlbuild.ml"
(* OASIS_STOP *)
Ocamlbuild_plugin.dispatch dispatch_default;;

let () = dispatch (function
| After_rules as e ->
flag ["doc"; "ocaml"] & (S [A"-keep-code"; A"-colorize-code";
A"-stars"; A"-charset"; A"utf8"]);
dispatch_default e
| e -> dispatch_default e);;
26 changes: 26 additions & 0 deletions src/sample.mli
Original file line number Diff line number Diff line change
Expand Up @@ -104,4 +104,30 @@ module KDE : sig
-> ?points:int
-> float array
-> (float array * float array)

(** {6 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
]}
{6 References}
+ B.W. Silverman, "Density Estimation for Statistics and Data
Analysis", Vol. 26, Monographs on Statistics and Applied
Probability, Chapman and Hall, London, 1986. *)
end

0 comments on commit 56799cc

Please sign in to comment.