finally fix types, but get numeric error

This commit is contained in:
NunoSempere 2023-10-15 00:53:58 +01:00
parent 4708c6f198
commit 710eb4267b
3 changed files with 2 additions and 2 deletions

Binary file not shown.

Binary file not shown.

View File

@ -65,13 +65,13 @@ let sampleTo low high =
sampleLognormal logmean logstd
let mixture (samplers: (unit -> float) list) (weights: float list): (float, string) result =
if (List.length samplers == List.length weights)
if (List.length samplers <> List.length weights)
then Error "in mixture function, List.length samplers != List.length weights"
else
let normalized_weights = normalizeXs weights in
let cumsummed_normalized_weights = cumsumXs normalized_weights in
let p = sampleZeroToOne () in
let chosenSamplerIndex = findIndex cumsummed_normalized_weights (fun x -> x < p) in
let chosenSamplerIndex = findIndex cumsummed_normalized_weights (fun x -> p < x) in
let sampler = match chosenSamplerIndex with
| Error e -> Error e
| Ok(i) -> nth samplers i