Added README to GenericDist library
This commit is contained in:
parent
3f678e24a1
commit
80b33fcd84
|
@ -28,8 +28,6 @@ let normalize = (t: t) =>
|
||||||
| #SampleSet(_) => t
|
| #SampleSet(_) => t
|
||||||
}
|
}
|
||||||
|
|
||||||
// let isNormalized = (t:t) =>
|
|
||||||
|
|
||||||
let operationToFloat = (toPointSet: toPointSetFn, fnName, t: genericDist): result<float, error> => {
|
let operationToFloat = (toPointSet: toPointSetFn, fnName, t: genericDist): result<float, error> => {
|
||||||
let symbolicSolution = switch t {
|
let symbolicSolution = switch t {
|
||||||
| #Symbolic(r) =>
|
| #Symbolic(r) =>
|
||||||
|
|
|
@ -21,6 +21,7 @@ type outputType = [
|
||||||
| #Dist(genericDist)
|
| #Dist(genericDist)
|
||||||
| #Error(error)
|
| #Error(error)
|
||||||
| #Float(float)
|
| #Float(float)
|
||||||
|
| #String(string)
|
||||||
]
|
]
|
||||||
|
|
||||||
let fromResult = (r: result<outputType, error>): outputType =>
|
let fromResult = (r: result<outputType, error>): outputType =>
|
||||||
|
@ -77,7 +78,7 @@ let rec run = (extra, fnName: operation): outputType => {
|
||||||
GenericDist.operationToFloat(toPointSet, fnName, dist)
|
GenericDist.operationToFloat(toPointSet, fnName, dist)
|
||||||
|> E.R.fmap(r => #Float(r))
|
|> E.R.fmap(r => #Float(r))
|
||||||
|> fromResult
|
|> fromResult
|
||||||
| #toString => #Error(GenericDist_Types.NotYetImplemented)
|
| #toString => dist |> GenericDist.toString |> (r => #String(r))
|
||||||
| #toDist(#normalize) => dist |> GenericDist.normalize |> (r => #Dist(r))
|
| #toDist(#normalize) => dist |> GenericDist.normalize |> (r => #Dist(r))
|
||||||
| #toDist(#truncate(left, right)) =>
|
| #toDist(#truncate(left, right)) =>
|
||||||
dist
|
dist
|
||||||
|
|
32
packages/squiggle-lang/src/rescript/GenericDist/README.md
Normal file
32
packages/squiggle-lang/src/rescript/GenericDist/README.md
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# Generic Distribution Library
|
||||||
|
|
||||||
|
This library provides one interface to generic distributions. These distributions can either be symbolic, point set (xy-coordinates of the shape), or sample set (arrays of random samples).
|
||||||
|
|
||||||
|
Different internal formats (symbolic, point set, sample set) allow for benefits and features. It's common for distributions to be converted into either point sets or sample sets to enable certain functions.
|
||||||
|
|
||||||
|
In addition to this interface, there's a second, generic function, for calling functions on this generic distribution type. This ``genericOperation`` standardizes the inputs and outputs for these various function calls. See it's ``run()`` function.
|
||||||
|
|
||||||
|
Performance is very important. Some operations can take a long time to run, and even then, be inaccurate. Because of this, we plan to have a lot of logging and stack tracing functionality eventually built in.
|
||||||
|
|
||||||
|
## Diagram of Distribution Types
|
||||||
|
```mermaid
|
||||||
|
graph TD
|
||||||
|
A[Generic Distribution] -->B{Point Set}
|
||||||
|
A --> C{Sample Set}
|
||||||
|
A --> D{Symbolic}
|
||||||
|
B ---> continuous(Continuous)
|
||||||
|
B ---> discrete(Discrete)
|
||||||
|
B --> mixed(Mixed)
|
||||||
|
continuous -.-> XYshape(XYshape)
|
||||||
|
discrete -.-> XYshape(XYshape)
|
||||||
|
mixed -.-> continuous
|
||||||
|
mixed -.-> discrete
|
||||||
|
D --> Normal(Normal)
|
||||||
|
D --> Lognormal(Lognormal)
|
||||||
|
D --> Triangular(Triangular)
|
||||||
|
D --> Beta(Beta)
|
||||||
|
D --> Uniform(Uniform)
|
||||||
|
D --> Float(Float)
|
||||||
|
D --> Exponential(Exponential)
|
||||||
|
D --> Cauchy(Cauchy)
|
||||||
|
```
|
Loading…
Reference in New Issue
Block a user