squiggle/packages/website/docs/Guides/Language.mdx
2022-06-24 03:43:30 +00:00

55 lines
1.0 KiB
Plaintext

---
sidebar_position: 1
title: Language Basics
---
import { SquiggleEditor } from "../../src/components/SquiggleEditor";
## Expressions
### Distributions
<SquiggleEditor squiggleString={`mixture(1 to 2, 3, [0.3, 0.7])`} />
### Numbers
<SquiggleEditor squiggleString="4.32" />
### Arrays
<SquiggleEditor
squiggleString={`[beta(1,10), 4, isNormalized(toSampleSet(1 to 2))]`}
/>
### Records
<SquiggleEditor
squiggleString={`d = {dist: triangular(0, 1, 2), weight: 0.25}
d.dist`}
/>
## Statements
A statement assigns expressions to names. It looks like `<symbol> = <expression>`
<SquiggleEditor
squiggleString={`value_of_work = 10 to 70
5 + value_of_work / 75`}
/>
### Functions
We can define functions
<SquiggleEditor
squiggleString={`ozzie_estimate(t) = lognormal(t^(1.1), 0.5)
nuno_estimate(t, m) = mixture(normal(-5, 1), lognormal(m, t / 1.25))
ozzie_estimate(1) * nuno_estimate(1, 1)`}
/>
## See more
- [Distribution creation](./DistributionCreation)
- [Functions reference](./Functions)
- [Gallery](../Discussions/Gallery)