Skip to content

Instantly share code, notes, and snippets.

@jzstark
Last active July 19, 2017 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jzstark/dec579b428c5a0109e3900d80117b627 to your computer and use it in GitHub Desktop.
Save jzstark/dec579b428c5a0109e3900d80117b627 to your computer and use it in GitHub Desktop.
Figures for owl_plot
(* qqplot *)
let y = Mat.(gaussian 100 1 *$ 10.) in
let x = Mat.gaussian 200 1 in
let h = Plot.create ~m:2 ~n:2 "" in
let _ = Plot.set_background_color h 28 28 28 in
let _ = Plot.subplot h 0 0 in
let _ = Plot.set_title h "Gaussian vs. Gaussian Sample" in
let _ = Plot.set_ylabel h "Quantiles of Input Sample" in
let _ = Plot.set_xlabel h "Normal Distribution Quantiles" in
let _ = Plot.qqplot ~h y ~x:x in
let _ = Plot.subplot h 0 1 in
let _ = Plot.set_title h "Gaussian vs. Default Dist" in
let _ = Plot.set_ylabel h "Quantiles of Input Sample" in
let _ = Plot.set_xlabel h "Normal Distribution Quantiles" in
let _ = Plot.qqplot ~h y ~spec:[RGB (0,128,255)] in
let _ = Plot.subplot h 1 0 in
let _ = Plot.set_title h "Gaussian vs. Rayleigh Dist" in
let _ = Plot.set_ylabel h "Quantiles of Input Sample" in
let _ = Plot.set_xlabel h "Rayleigh Distribution (sigma=0.5) Quantiles" in
let _ = Plot.qqplot ~h y ~pd:(fun p -> Stats.Cdf.rayleigh_Pinv p 0.5) in
let _ = Plot.subplot h 1 1 in
let _ = Plot.set_title h "Gaussian vs. Chi-Square Dist" in
let _ = Plot.set_ylabel h "Quantiles of Input Sample" in
let _ = Plot.set_xlabel h "Chi-Square Distribution (k=10) Quantiles" in
let _ = Plot.qqplot ~h y ~pd:(fun p -> Stats.Cdf.chisq_Pinv p 10.) in
Plot.output h;;
(* probplot *)
let x = Mat.empty 200 1 |> Mat.map (fun _ -> Stats.Rnd.weibull 1.2 1.5) in
let h = Plot.create ~m:1 ~n:2 "weibull.png" in
let _ = Plot.set_background_color h 28 28 28 in
let _ = Plot.subplot h 0 0 in
let _ = Plot.set_title h "Random Weibull Sample vs. Std Normal Dist" in
let _ = Plot.set_xlabel h "Sample Data" in
let _ = Plot.set_ylabel h "Theoratical Normal Dist" in
let _ = Plot.normplot ~h x in
let _ = Plot.subplot h 0 1 in
let _ = Plot.set_title h "Random Weibull Sample vs. Weibull Dist" in
let _ = Plot.set_xlabel h "Sample Data" in
let _ = Plot.set_ylabel h "Theoratical Weibull Dist" in
let _ = Plot.wblplot ~h ~lambda:1.2 ~k:1.5 x in
Plot.output h;;
(* loglog *)
let x = Mat.logspace (-1.5) 2. 50 in
let y = Mat.map Maths.exp x in
let h = Plot.create ~m:2 ~n:2 "log.png" in
let _ = Plot.subplot h 0 0 in
let _ = Plot.set_xlabel h "Input Data X" in
let _ = Plot.set_ylabel h "Input Data Y" in
let _ = Plot.(loglog ~h ~spec:[ RGB (0,255,0); LineStyle 2; Marker "+" ] ~x:x y) in
let _ = Plot.subplot h 0 1 in
let _ = Plot.set_xlabel h "Index of Input Data Y" in
let _ = Plot.set_ylabel h "Input Data Y" in
let _ = Plot.(loglog ~h ~spec:[ RGB (0,0,255); LineStyle 1; Marker "*" ] y) in
let _ = Plot.subplot h 1 0 in
let _ = Plot.set_xlabel h "Input Data X" in
let _ = Plot.set_ylabel h "Input Data Y" in
let _ = Plot.semilogx ~h ~x:x y in
let _ = Plot.subplot h 1 1 in
let _ = Plot.set_xlabel h "Index of Input Data Y" in
let _ = Plot.set_ylabel h "Input Data Y" in
let _ = Plot.semilogy ~h y in
Plot.output h;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment