commit ce119253b7af4003ca9dc5f634bbfd9e8da06fe6 parent 90e48d2249fd451286322586336afe67f94d9280 Author: NunoSempere <nuno.sempere@protonmail.com> Date: Sat, 14 Oct 2023 23:59:40 +0100 tweak: give up on piping to Some Diffstat:
| M | ocaml/out/samples | | | 0 | |
| M | ocaml/out/samples.cmi | | | 0 | |
| M | ocaml/out/samples.cmx | | | 0 | |
| M | ocaml/out/samples.o | | | 0 | |
| M | ocaml/samples.ml | | | 5 | +++-- |
5 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/ocaml/out/samples b/ocaml/out/samples Binary files differ. diff --git a/ocaml/out/samples.cmi b/ocaml/out/samples.cmi Binary files differ. diff --git a/ocaml/out/samples.cmx b/ocaml/out/samples.cmx Binary files differ. diff --git a/ocaml/out/samples.o b/ocaml/out/samples.o Binary files differ. diff --git a/ocaml/samples.ml b/ocaml/samples.ml @@ -41,7 +41,8 @@ let sampleTo low high = let logstd = (loghigh -. loglow) /. (2.0 -. normal_95_ci_length ) in sampleLognormal logmean logstd -let mixture (samplers: (unit -> float) array) (weights: float array) = +let (|>) x f = f x +let mixture (samplers: (unit -> float) array) (weights: float array): float option = match (Array.length samplers == Array.length weights) with | false -> None | true -> @@ -51,7 +52,7 @@ let mixture (samplers: (unit -> float) array) (weights: float array) = let chosenSamplerIndex = findIndex cumsummed_normalized_weights (fun x -> x < p) in let sample = match chosenSamplerIndex with | None -> None - | Some(i) -> Some((samplers.(i) ())) (* (samplers.(i) ()) |> Some *) + | Some(i) -> Some(samplers.(i) ()) in sample