Added simple interface files
This commit is contained in:
parent
04abeb7cd1
commit
6f11e87c0a
|
@ -1,9 +1,10 @@
|
|||
//TODO: multimodal, add interface, test somehow, track performance, refactor sampleSet, refactor ASTEvaluator.res.
|
||||
type genericDist = GenericDist_Types.genericDist
|
||||
type t = GenericDist_Types.genericDist
|
||||
type error = GenericDist_Types.error
|
||||
type toPointSetFn = genericDist => result<PointSetTypes.pointSetDist, error>
|
||||
type toSampleSetFn = genericDist => result<array<float>, error>
|
||||
type t = genericDist
|
||||
type toPointSetFn = t => result<PointSetTypes.pointSetDist, error>
|
||||
type toSampleSetFn = t => result<array<float>, error>
|
||||
type scaleMultiplyFn = (t, float) => result<t, error>
|
||||
type pointwiseAddFn = (t, t) => result<t, error>
|
||||
|
||||
let sampleN = (n, t: t) =>
|
||||
switch t {
|
||||
|
@ -28,7 +29,7 @@ let normalize = (t: t) =>
|
|||
| #SampleSet(_) => t
|
||||
}
|
||||
|
||||
let operationToFloat = (toPointSet: toPointSetFn, fnName, t: genericDist): result<float, error> => {
|
||||
let operationToFloat = (toPointSet: toPointSetFn, fnName, t) => {
|
||||
let symbolicSolution = switch t {
|
||||
| #Symbolic(r) =>
|
||||
switch SymbolicDist.T.operate(fnName, r) {
|
||||
|
@ -220,9 +221,9 @@ let pointwiseCombinationFloat = (
|
|||
}
|
||||
|
||||
let mixture = (
|
||||
scaleMultiply: (genericDist, float) => result<genericDist, error>,
|
||||
pointwiseAdd: (genericDist, genericDist) => result<genericDist, error>,
|
||||
values: array<(genericDist, float)>,
|
||||
scaleMultiply: scaleMultiplyFn,
|
||||
pointwiseAdd: pointwiseAddFn,
|
||||
values: array<(t, float)>,
|
||||
) => {
|
||||
if E.A.length(values) == 0 {
|
||||
Error(GenericDist_Types.Other("mixture must have at least 1 element"))
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
type t = GenericDist_Types.genericDist
|
||||
type error = GenericDist_Types.error
|
||||
type toPointSetFn = t => result<PointSetTypes.pointSetDist, error>
|
||||
type toSampleSetFn = t => result<array<float>, error>
|
||||
type scaleMultiplyFn = (t, float) => result<t, error>
|
||||
type pointwiseAddFn = (t, t) => result<t, error>
|
||||
|
||||
let sampleN: (int, t) => result<array<float>, error>
|
||||
|
||||
let fromFloat: float => t
|
||||
|
||||
let toString: t => string
|
||||
|
||||
let normalize: t => t
|
||||
|
||||
let operationToFloat: (toPointSetFn, Operation.distToFloatOperation, t) => result<float, error>
|
||||
|
||||
let toPointSet: (int, t) => result<PointSetTypes.pointSetDist, error>
|
||||
|
||||
let truncate: (toPointSetFn, option<float>, option<float>, t) => result<t, error>
|
||||
|
||||
let algebraicCombination: (
|
||||
toPointSetFn,
|
||||
toSampleSetFn,
|
||||
GenericDist_Types.Operation.arithmeticOperation,
|
||||
t,
|
||||
t,
|
||||
) => result<t, error>
|
||||
|
||||
let pointwiseCombination: (
|
||||
toPointSetFn,
|
||||
GenericDist_Types.Operation.arithmeticOperation,
|
||||
t,
|
||||
t,
|
||||
) => result<t, error>
|
||||
|
||||
let pointwiseCombinationFloat: (
|
||||
toPointSetFn,
|
||||
GenericDist_Types.Operation.arithmeticOperation,
|
||||
float,
|
||||
t,
|
||||
) => result<t, error>
|
||||
|
||||
let mixture: (scaleMultiplyFn, pointwiseAddFn, array<(t, float)>) => result<t, error>
|
|
@ -1,4 +1,4 @@
|
|||
type operation = GenericDist_Types.Operation.genericFunction
|
||||
type operation = GenericDist_Types.Operation.genericFunctionCall
|
||||
type genericDist = GenericDist_Types.genericDist
|
||||
type error = GenericDist_Types.error
|
||||
|
||||
|
@ -9,14 +9,6 @@ type params = {
|
|||
xyPointLength: int,
|
||||
}
|
||||
|
||||
let genericParams = {
|
||||
sampleCount: 1000,
|
||||
xyPointLength: 1000,
|
||||
}
|
||||
|
||||
type wrapped = (genericDist, params)
|
||||
|
||||
let wrapWithParams = (g: genericDist, f: params): wrapped => (g, f)
|
||||
type outputType = [
|
||||
| #Dist(genericDist)
|
||||
| #Error(error)
|
||||
|
@ -82,7 +74,7 @@ let rec run = (extra, fnName: operation): outputType => {
|
|||
| #toDist(#normalize) => dist |> GenericDist.normalize |> (r => #Dist(r))
|
||||
| #toDist(#truncate(left, right)) =>
|
||||
dist
|
||||
|> GenericDist.Truncate.run(toPointSet, left, right)
|
||||
|> GenericDist.truncate(toPointSet, left, right)
|
||||
|> E.R.fmap(r => #Dist(r))
|
||||
|> fromResult
|
||||
| #toDist(#toPointSet) =>
|
||||
|
@ -95,7 +87,7 @@ let rec run = (extra, fnName: operation): outputType => {
|
|||
| #toDistCombination(#Algebraic, _, #Float(_)) => #Error(NotYetImplemented)
|
||||
| #toDistCombination(#Algebraic, operation, #Dist(dist2)) =>
|
||||
dist
|
||||
|> GenericDist.AlgebraicCombination.run(toPointSet, toSampleSet, operation, dist2)
|
||||
|> GenericDist.algebraicCombination(toPointSet, toSampleSet, operation, dist2)
|
||||
|> E.R.fmap(r => #Dist(r))
|
||||
|> fromResult
|
||||
| #toDistCombination(#Pointwise, operation, #Dist(dist2)) =>
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
type params = {
|
||||
sampleCount: int,
|
||||
xyPointLength: int,
|
||||
}
|
||||
|
||||
type outputType = [
|
||||
| #Dist(GenericDist_Types.genericDist)
|
||||
| #Error(GenericDist_Types.error)
|
||||
| #Float(float)
|
||||
| #String(string)
|
||||
]
|
||||
|
||||
let run: (params, GenericDist_Types.Operation.genericFunctionCall) => outputType
|
|
@ -61,7 +61,7 @@ module Operation = {
|
|||
| #toString
|
||||
]
|
||||
|
||||
type genericFunction = [
|
||||
type genericFunctionCall = [
|
||||
| #fromDist(fromDist, genericDist)
|
||||
| #fromFloat(fromDist, float)
|
||||
| #mixture(array<(genericDist, float)>)
|
||||
|
|
|
@ -33,7 +33,6 @@ graph TD
|
|||
|
||||
## Todo
|
||||
- [ ] Lots of cleanup
|
||||
- [ ] Add interface files
|
||||
- [ ] Simple test story
|
||||
- [ ] Provide decent stack traces for key calls in GenericOperation. This could be very useful for debugging.
|
||||
- [ ] Cleanup Sample Set library
|
||||
|
|
Loading…
Reference in New Issue
Block a user