2022-03-25 02:08:46 +00:00
|
|
|
---
|
2022-05-10 19:23:04 +00:00
|
|
|
sidebar_position: 1
|
2022-04-27 20:28:10 +00:00
|
|
|
title: Language Basics
|
2022-03-25 02:08:46 +00:00
|
|
|
---
|
|
|
|
|
2022-04-11 00:13:11 +00:00
|
|
|
import { SquiggleEditor } from "../../src/components/SquiggleEditor";
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-04-28 14:58:39 +00:00
|
|
|
## Expressions
|
2022-04-27 18:49:15 +00:00
|
|
|
|
2022-05-03 21:22:08 +00:00
|
|
|
### Distributions
|
2022-04-27 18:49:15 +00:00
|
|
|
|
|
|
|
<SquiggleEditor initialSquiggleString={`mixture(1 to 2, 3, [0.3, 0.7])`} />
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-05-03 21:22:08 +00:00
|
|
|
### Numbers
|
2022-04-27 18:49:15 +00:00
|
|
|
|
2022-05-03 21:22:08 +00:00
|
|
|
<SquiggleEditor initialSquiggleString="4.32" />
|
2022-04-28 14:58:39 +00:00
|
|
|
|
2022-05-03 21:22:08 +00:00
|
|
|
### Arrays
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-04-10 23:15:46 +00:00
|
|
|
<SquiggleEditor
|
2022-04-28 15:21:10 +00:00
|
|
|
initialSquiggleString={`[beta(1,10), 4, isNormalized(toSampleSet(1 to 2))]`}
|
2022-04-10 23:15:46 +00:00
|
|
|
/>
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-05-03 21:22:08 +00:00
|
|
|
### Records
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-04-28 15:21:10 +00:00
|
|
|
<SquiggleEditor
|
|
|
|
initialSquiggleString={`d = {dist: triangular(0, 1, 2), weight: 0.25}
|
|
|
|
d.dist`}
|
|
|
|
/>
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-04-28 14:58:39 +00:00
|
|
|
## Statements
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-04-28 14:58:39 +00:00
|
|
|
A statement assigns expressions to names. It looks like `<symbol> = <expression>`
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-04-27 18:49:15 +00:00
|
|
|
<SquiggleEditor
|
2022-04-28 14:58:39 +00:00
|
|
|
initialSquiggleString={`value_of_work = 10 to 70
|
|
|
|
5 + value_of_work / 75`}
|
2022-04-27 18:49:15 +00:00
|
|
|
/>
|
|
|
|
|
2022-04-28 14:58:39 +00:00
|
|
|
### Functions
|
|
|
|
|
|
|
|
We can define functions
|
2022-03-25 02:08:46 +00:00
|
|
|
|
2022-04-10 23:15:46 +00:00
|
|
|
<SquiggleEditor
|
2022-05-03 21:22:08 +00:00
|
|
|
initialSquiggleString={`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)`}
|
2022-04-10 23:15:46 +00:00
|
|
|
/>
|
2022-04-28 15:21:10 +00:00
|
|
|
|
|
|
|
## See more
|
|
|
|
|
2022-05-20 15:46:10 +00:00
|
|
|
- [Distribution creation](/Distributions)
|
|
|
|
- [Functions reference](/Functions)
|
|
|
|
- [Gallery](../Discussions/Gallery)
|