squiggle/packages/components/src/stories/SquiggleChart.stories.mdx

93 lines
1.8 KiB
Plaintext
Raw Normal View History

2022-03-23 00:38:01 +00:00
import { SquiggleChart } from "../SquiggleChart";
import { Canvas, Meta, Story, Props } from "@storybook/addon-docs";
2022-03-23 00:38:01 +00:00
<Meta title="Squiggle/SquiggleChart" component={SquiggleChart} />
2022-03-23 00:38:01 +00:00
export const Template = SquiggleChart;
# Squiggle Chart
Squiggle chart evaluates squiggle expressions, and then returns a graph representing
the result of a squiggle expression.
A squiggle expression can have three different types of returns. A distribution,
a constant, and a function.
A distribution means that the result forms a probability distribution. This
could be continuous, discrete or mixed.
## Distributions
An example of a normal distribution is:
2022-03-23 00:38:01 +00:00
<Canvas>
<Story
name="Normal"
args={{
2022-03-23 00:38:01 +00:00
squiggleString: "normal(5,2)",
}}
>
{Template.bind({})}
</Story>
</Canvas>
An example of a Discrete distribution is:
2022-03-23 00:38:01 +00:00
<Canvas>
<Story
name="Discrete"
args={{
2022-03-23 00:38:01 +00:00
squiggleString: "mm(0, 1, [0.5, 0.5])",
}}
>
{Template.bind({})}
</Story>
</Canvas>
An example of a Mixed distribution is:
2022-03-23 00:38:01 +00:00
<Canvas>
<Story
name="Mixed"
args={{
2022-03-23 00:38:01 +00:00
squiggleString: "mm(0, 5 to 10, [0.5, 0.5])",
}}
>
{Template.bind({})}
</Story>
</Canvas>
## Constants
2022-03-23 00:38:01 +00:00
A constant is a simple number as a result. This has special formatting rules
to allow large and small numbers being printed cleanly.
2022-03-23 00:38:01 +00:00
<Canvas>
<Story
name="Constant"
args={{
2022-03-23 00:38:01 +00:00
squiggleString: "500000 * 5000000",
}}
>
{Template.bind({})}
</Story>
</Canvas>
## Functions
2022-03-23 00:38:01 +00:00
Finally, a function can be returned, and this shows how the distribution changes
over the axis between x = 0 and 10.
<Canvas>
<Story
name="Function"
args={{
2022-03-23 00:38:01 +00:00
squiggleString: "f(x) = normal(x,x)\nf",
}}
>
{Template.bind({})}
</Story>
</Canvas>
<Props of={SquiggleChart} />