Added ExpressionTreeExamples in showcase

This commit is contained in:
Ozzie Gooen 2020-07-02 23:52:58 +01:00
parent a681135f3d
commit a649a6bca2
4 changed files with 74 additions and 3 deletions

View File

@ -1 +1 @@
let entries = EntryTypes.[Continuous.entry]; let entries = EntryTypes.[Continuous.entry,ExpressionTreeExamples.entry];

View File

@ -84,4 +84,4 @@ let distributions = () =>
</div> </div>
</div>; </div>;
let entry = EntryTypes.(entry(~title="Pdf", ~render=distributions)); let entry = EntryTypes.(entry(~title="Mixed Distributions", ~render=distributions));

View File

@ -0,0 +1,71 @@
let setup = dist =>
RenderTypes.DistPlusRenderer.make(~distPlusIngredients=dist, ())
|> DistPlusRenderer.run
|> RenderTypes.DistPlusRenderer.Outputs.distplus
|> R.O.fmapOrNull(distPlus => <DistPlusPlot distPlus />);
let simpleExample = (guesstimatorString, ~problem="", ()) =>
<>
<p> {guesstimatorString |> ReasonReact.string} </p>
<p> {problem |> (e => "problem: " ++ e) |> ReasonReact.string} </p>
{setup(
RenderTypes.DistPlusRenderer.Ingredients.make(~guesstimatorString, ()),
)}
</>;
let distributions = () =>
<div>
<div>
<h2 className="text-gray-800 text-xl font-bold">
{"Initial Section" |> ReasonReact.string}
</h2>
{simpleExample(
"normal(-1, 1) + normal(5, 2)",
~problem="Tails look too flat",
(),
)}
{simpleExample(
"mm(normal(4,2), normal(10,1))",
~problem="Tails look too flat",
(),
)}
{simpleExample(
"normal(-1, 1) * normal(5, 2)",
~problem="This looks really weird",
(),
)}
{simpleExample(
"normal(1,2) * normal(2,2) * normal(3,1)",
~problem="Seems like important parts are cut off",
(),
)}
{simpleExample(
"mm(uniform(0, 1) , normal(3,2))",
~problem="Uniform distribution seems to break multimodal",
(),
)}
{simpleExample(
"truncate(mm(1 to 10, 10 to 30), 10, 20)",
~problem="Truncate seems to have no effect",
(),
)}
{simpleExample(
"normal(5,2)*(10^3)",
~problem="Multiplied items should be evaluated.",
(),
)}
{simpleExample(
"normal(5,10*3)",
~problem="At least simple operations in the distributions should be evaluated.",
(),
)}
{simpleExample(
"normal(5,10)^3",
~problem="Exponentiation not yet supported",
(),
)}
</div>
</div>;
let entry =
EntryTypes.(entry(~title="ExpressionTree", ~render=distributions));

View File

@ -85,7 +85,7 @@ module T = {
Pointwise.format(op, nodeToString(t1), nodeToString(t2)) Pointwise.format(op, nodeToString(t1), nodeToString(t2))
| `VerticalScaling(scaleOp, t, scaleBy) => | `VerticalScaling(scaleOp, t, scaleBy) =>
Scale.format(scaleOp, nodeToString(t), nodeToString(scaleBy)) Scale.format(scaleOp, nodeToString(t), nodeToString(scaleBy))
| `Normalize(t) => "normalize(" ++ nodeToString(t) ++ ")" | `Normalize(t) => "normalize(k" ++ nodeToString(t) ++ ")"
| `FloatFromDist(floatFromDistOp, t) => | `FloatFromDist(floatFromDistOp, t) =>
DistToFloat.format(floatFromDistOp, nodeToString(t)) DistToFloat.format(floatFromDistOp, nodeToString(t))
| `Truncate(lc, rc, t) => truncateToString(lc, rc, nodeToString(t)) | `Truncate(lc, rc, t) => truncateToString(lc, rc, nodeToString(t))