Fixed issue with mixed distributions
This commit is contained in:
parent
0ef6d106ea
commit
88358470e3
|
@ -100,9 +100,9 @@ module T = {
|
||||||
|> E.FloatFloatMap.toArray
|
|> E.FloatFloatMap.toArray
|
||||||
|> XYShape.T.fromZippedArray;
|
|> XYShape.T.fromZippedArray;
|
||||||
let pdf: DistTypes.xyShape =
|
let pdf: DistTypes.xyShape =
|
||||||
continuousPart |> E.A.length > 20
|
continuousPart |> E.A.length > 5
|
||||||
? {
|
? {
|
||||||
samples |> KDE.normalSampling(_, outputXYPoints, kernelWidth);
|
continuousPart |> KDE.normalSampling(_, outputXYPoints, kernelWidth);
|
||||||
}
|
}
|
||||||
: {xs: [||], ys: [||]};
|
: {xs: [||], ys: [||]};
|
||||||
let continuous = pdf |> Distributions.Continuous.make(`Linear);
|
let continuous = pdf |> Distributions.Continuous.make(`Linear);
|
||||||
|
|
|
@ -156,14 +156,17 @@ module MathAdtToDistDst = {
|
||||||
args
|
args
|
||||||
|> E.A.fmap(
|
|> E.A.fmap(
|
||||||
fun
|
fun
|
||||||
| Ok(`Simple(n)) => Some(n)
|
| Ok(`Simple(n)) => Ok(n)
|
||||||
| _ => None,
|
| Error(e) => Error(e)
|
||||||
|
| _ => Error("Type not supported"),
|
||||||
)
|
)
|
||||||
|> E.A.O.concatSomes;
|
let firstWithError = dists |> Belt.Array.getBy(_, Belt.Result.isError);
|
||||||
switch (dists |> E.A.length) {
|
let withoutErrors = dists |> E.A.fmap(E.R.toOption) |> E.A.O.concatSomes;
|
||||||
| 0 => Error("Multimodals need at least one input")
|
switch (firstWithError ) {
|
||||||
|
| (Some(Error(e))) => Error(e)
|
||||||
|
| (None) when (withoutErrors |> E.A.length == 0) => Error("Multimodals need at least one input")
|
||||||
| _ =>
|
| _ =>
|
||||||
dists
|
withoutErrors
|
||||||
|> E.A.fmapi((index, item) =>
|
|> E.A.fmapi((index, item) =>
|
||||||
(item, weights |> E.A.get(_, index) |> E.O.default(1.0))
|
(item, weights |> E.A.get(_, index) |> E.O.default(1.0))
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user