Formatter
This commit is contained in:
parent
93f4c1e0c2
commit
b87e952785
|
@ -63,9 +63,15 @@ describe("FunctionRegistry Library", () => {
|
||||||
testEvalToBe("SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
|
testEvalToBe("SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
|
||||||
testEvalToBe("SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
|
testEvalToBe("SampleSet.fromList([3,5,2,3,5,2,3,5,2,3,3,5])", "Ok(Sample Set Distribution)")
|
||||||
testEvalToBe("SampleSet.fromFn({|| sample(normal(5,2))})", "Ok(Sample Set Distribution)")
|
testEvalToBe("SampleSet.fromFn({|| sample(normal(5,2))})", "Ok(Sample Set Distribution)")
|
||||||
testEvalToBe("SampleSet.min(SampleSet.fromDist(normal(50,2)), 2)", "Ok(Sample Set Distribution)")
|
testEvalToBe(
|
||||||
|
"SampleSet.min(SampleSet.fromDist(normal(50,2)), 2)",
|
||||||
|
"Ok(Sample Set Distribution)",
|
||||||
|
)
|
||||||
testEvalToBe("mean(SampleSet.min(SampleSet.fromDist(normal(50,2)), 2))", "Ok(2)")
|
testEvalToBe("mean(SampleSet.min(SampleSet.fromDist(normal(50,2)), 2))", "Ok(2)")
|
||||||
testEvalToBe("SampleSet.max(SampleSet.fromDist(normal(50,2)), 10)", "Ok(Sample Set Distribution)")
|
testEvalToBe(
|
||||||
|
"SampleSet.max(SampleSet.fromDist(normal(50,2)), 10)",
|
||||||
|
"Ok(Sample Set Distribution)",
|
||||||
|
)
|
||||||
testEvalToBe(
|
testEvalToBe(
|
||||||
"addOne(t)=t+1; SampleSet.toList(SampleSet.map(SampleSet.fromList([1,2,3,4,5,6]), addOne))",
|
"addOne(t)=t+1; SampleSet.toList(SampleSet.map(SampleSet.fromList([1,2,3,4,5,6]), addOne))",
|
||||||
"Ok([2,3,4,5,6,7])",
|
"Ok([2,3,4,5,6,7])",
|
||||||
|
|
|
@ -302,13 +302,15 @@ module T = Dist({
|
||||||
}
|
}
|
||||||
|
|
||||||
let sampleN = (t: t, n: int): array<float> => {
|
let sampleN = (t: t, n: int): array<float> => {
|
||||||
let discreteIntegralSum = discreteIntegralSum(t);
|
let discreteIntegralSum = discreteIntegralSum(t)
|
||||||
let integralSum = integralSum(t);
|
let integralSum = integralSum(t)
|
||||||
let discreteSampleLength:int = (Js.Int.toFloat(n) *. discreteIntegralSum /. integralSum) -> E.Float.toInt
|
let discreteSampleLength: int =
|
||||||
let continuousSampleLength = n - discreteSampleLength;
|
(Js.Int.toFloat(n) *. discreteIntegralSum /. integralSum)->E.Float.toInt
|
||||||
let continuousSamples = t.continuous ->Continuous.T.normalize-> Continuous.T.sampleN( continuousSampleLength)
|
let continuousSampleLength = n - discreteSampleLength
|
||||||
|
let continuousSamples =
|
||||||
|
t.continuous->Continuous.T.normalize->Continuous.T.sampleN(continuousSampleLength)
|
||||||
let discreteSamples = t.discrete->Discrete.T.normalize->Discrete.T.sampleN(discreteSampleLength)
|
let discreteSamples = t.discrete->Discrete.T.normalize->Discrete.T.sampleN(discreteSampleLength)
|
||||||
Js.log3("Samples", continuousSamples, discreteSamples);
|
Js.log3("Samples", continuousSamples, discreteSamples)
|
||||||
E.A.concat(discreteSamples, continuousSamples)->E.A.shuffle
|
E.A.concat(discreteSamples, continuousSamples)->E.A.shuffle
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user