This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
open Lacaml.D | |
let capture_failure_of_list = function | |
| [] -> Mat.empty | |
| (h :: _) as lst -> | |
let m = List.length lst in | |
let n = List.length h in | |
let mat = Mat.create m n in | |
let rec loop i = function | |
| [] -> mat |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# let pred = | |
Array.init 100 (fun r -> | |
let a = n1 () in | |
let b = n1 () in | |
let c = a +. b in (* Makes the third column/predictor redundant and our data collinear! *) | |
[|a;b;c|]) ;; | |
val pred : float array array = | |
[|[|2.1000; 0.9001; 3.0001|]; [|1.7343; 2.9934; 4.7277|]; [|2.7644; 4.0290; 6.7935|]; | |
[|0.7972; 2.6754; 3.4726|]; [|0.6089; 2.7250; 3.3340|]; [|0.7870; 2.7721; 3.5592|]; | |
...|] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data | |
|> List.filter (fun (s,_,_) -> s = "HLA-A-3101") | |
|> List.map (fun (_,a,b) -> (a,b)) | |
|> Array.of_list | |
|> (fun arr -> [|0;9;18;27;36|] | |
|> Array.map (fun s -> Array.sub arr s 9 | |
|> Array.to_list | |
|> List.sort (fun (_,v1) (_,v2) -> compare v2 v1) | |
|> Array.of_list) | |
|> transpose) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# #require "oml" ;; | |
# #show_module Oml ;; | |
module Oml : | |
sig | |
module Util : sig end | |
module Vectors : sig end | |
module Matrices : sig end | |
module Continued_fraction : sig end | |
module Functions : sig end | |
module Distributions : sig end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# let shorter_float_printer fr = Format.fprintf fr "%0.4f" ;; | |
val shorter_float_printer : Format.formatter -> float -> unit = <fun> | |
# #install_printer shorter_float_printer ;; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# let n1 = Sampling.normal ~mean:2. ~std:1. () ;; | |
val n1 : float Oml.Sampling.generator = <fun> | |
# let n2 = Sampling.normal ~mean:2. ~std:10. () ;; | |
val n2 : float Oml.Sampling.generator = <fun> | |
# let data = | |
Array.init 10000 (fun i -> if i mod 10 = 0 then n2 () else n1 ()) ;; | |
val data : float array | |
= [|4.9157; 0.5018; 1.9781; 3.1645; 2.6965; 2.8426; ... |] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Descriptive.unbiased_summary data ;; | |
- : Descriptive.summary = | |
{Descriptive.size = 10000; | |
min = -28.4799; | |
max = 36.8804; | |
mean = 1.9916; | |
std = 3.3391; | |
var = 11.1497; | |
skew = (-0.2382, `Negative); | |
kurtosis = (23.2732, `Fat) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# let data_skew ftf = | |
Array.init 10000 (fun i -> if i mod ftf = 0 then n2 () else n1()) | |
|> Descriptive.unbiased_summary | |
|> fun s -> s.Descriptive.skew | |
|> snd ;; | |
val data_skew : int -> Oml.Descriptive.skew_classification = <fun> | |
# let count_big_skew = | |
Array.fold_left (fun c s -> | |
if s = `Positive || s = `Negative then c + 1 else c) 0 ;; | |
val count_big_skew : _[> `Negative | `Positive ] array -> int = <fun> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Inference.mean_t_test 2.0 Inference.Two_sided data ;; | |
- : Oml.Inference.test = {Oml.Inference.degrees_of_freedom = 9999.0000; statistic = -0.2509; standard_error = 0.0334; prob_by_chance = 0.8019} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# let pred = Array.init 100 (fun r -> Array.init 3 (fun _ -> n1 ())) ;; | |
val pred : float array array = | |
[|[|2.8291; 2.0174; 2.3971|]; | |
[|1.5963; 2.0713; 2.3183|]; | |
[|1.5755; 0.5216; 2.8682|]; | |
[|1.9523; 0.4255; 3.6062|]; | |
[|2.5397; 3.8247; 3.4417|]; ...|] | |
# let resp = Array.map (fun arr -> 2. +. 3. *. arr.(0) +. 4. *. arr.(1) +. 5. *. arr.(2)) pred ;; | |
val resp : float array = | |
[|30.5424; 26.6658; 23.1534; 27.5899; 33.7047; 21.5728; 16.6898; 20.5841; 17.1497; ...|] |
NewerOlder