finally fix types, but get numeric error
This commit is contained in:
parent
4708c6f198
commit
710eb4267b
Binary file not shown.
Binary file not shown.
|
@ -65,13 +65,13 @@ let sampleTo low high =
|
||||||
sampleLognormal logmean logstd
|
sampleLognormal logmean logstd
|
||||||
|
|
||||||
let mixture (samplers: (unit -> float) list) (weights: float list): (float, string) result =
|
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"
|
then Error "in mixture function, List.length samplers != List.length weights"
|
||||||
else
|
else
|
||||||
let normalized_weights = normalizeXs weights in
|
let normalized_weights = normalizeXs weights in
|
||||||
let cumsummed_normalized_weights = cumsumXs normalized_weights in
|
let cumsummed_normalized_weights = cumsumXs normalized_weights in
|
||||||
let p = sampleZeroToOne () 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
|
let sampler = match chosenSamplerIndex with
|
||||||
| Error e -> Error e
|
| Error e -> Error e
|
||||||
| Ok(i) -> nth samplers i
|
| Ok(i) -> nth samplers i
|
||||||
|
|
Loading…
Reference in New Issue
Block a user