Formatted
This commit is contained in:
parent
f7834b0f46
commit
b37e372815
|
@ -9,7 +9,7 @@ Much of the Squiggle math is imprecise. This can cause significant errors, so wa
|
|||
|
||||
Below are a few specific examples to watch for. We'll work on improving these over time and adding much better warnings and error management.
|
||||
|
||||
## Operations on very small or large numbers, silently round to 0 and 1
|
||||
## Operations on very small or large numbers, silently round to 0 and 1
|
||||
|
||||
Squiggle is poor at dealing with very small or large numbers, given fundamental limitations of floating point precision.
|
||||
See [this Github Issue](https://github.com/quantified-uncertainty/squiggle/issues/834).
|
||||
|
|
|
@ -35,7 +35,9 @@ If both values are above zero, a `lognormal` distribution is used. If not, a `no
|
|||
<SquiggleEditor defaultCode="-5 to -3" />
|
||||
</TabItem>
|
||||
<TabItem value="ex4" label="1 to 10000">
|
||||
It's very easy to generate distributions with very long tails. These can be impossible to see without changing view settings. (These settings are available in the Playground, but not this smaller editor component)
|
||||
It's very easy to generate distributions with very long tails. These can be
|
||||
impossible to see without changing view settings. (These settings are
|
||||
available in the Playground, but not this smaller editor component)
|
||||
<SquiggleEditor defaultCode="1 to 10000" />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
@ -283,10 +285,7 @@ Creates a [beta distribution](https://en.wikipedia.org/wiki/Beta_distribution) w
|
|||
<TabItem value="ex5" label="beta(0.8, 0.8)">
|
||||
<SquiggleEditor defaultCode="beta(0.8, 0.8)" />
|
||||
</TabItem>
|
||||
<TabItem
|
||||
value="ex6"
|
||||
label="beta({mean: 0.39, stdev: 0.1})"
|
||||
>
|
||||
<TabItem value="ex6" label="beta({mean: 0.39, stdev: 0.1})">
|
||||
<SquiggleEditor defaultCode="beta({mean: 0.39, stdev: 0.1})" />
|
||||
</TabItem>
|
||||
</Tabs>
|
||||
|
@ -378,12 +377,14 @@ Creates a sample set distribution using an array of samples.
|
|||
|
||||
Creates a continuous point set distribution using a list of points.
|
||||
|
||||
<SquiggleEditor defaultCode={`PointSet.makeContinuous([
|
||||
<SquiggleEditor
|
||||
defaultCode={`PointSet.makeContinuous([
|
||||
{ x: 0, y: 0.1 },
|
||||
{ x: 1, y: 0.2 },
|
||||
{ x: 2, y: 0.15 },
|
||||
{ x: 3, y: 0.1 }
|
||||
])`} />
|
||||
])`}
|
||||
/>
|
||||
|
||||
### Arguments
|
||||
|
||||
|
@ -395,12 +396,14 @@ Creates a continuous point set distribution using a list of points.
|
|||
|
||||
Creates a discrete point set distribution using a list of points.
|
||||
|
||||
<SquiggleEditor defaultCode={`PointSet.makeDiscrete([
|
||||
<SquiggleEditor
|
||||
defaultCode={`PointSet.makeDiscrete([
|
||||
{ x: 0, y: 0.1 },
|
||||
{ x: 1, y: 0.2 },
|
||||
{ x: 2, y: 0.15 },
|
||||
{ x: 3, y: 0.1 }
|
||||
])`} />
|
||||
])`}
|
||||
/>
|
||||
|
||||
### Arguments
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ Squiggle supports some simple types and language features.
|
|||
<SquiggleEditor defaultCode="4.32" />
|
||||
|
||||
## Distributions
|
||||
|
||||
There are several ways of easily entering distributions. See the [documentation](/docs/Api/Dist/) on distributions for a complete API.
|
||||
|
||||
<SquiggleEditor
|
||||
|
@ -23,6 +24,7 @@ d`}
|
|||
/>
|
||||
|
||||
## Lists
|
||||
|
||||
Squiggle lists can accept items of any type, similar to those in Python. [API](/docs/Api/List).
|
||||
|
||||
<SquiggleEditor
|
||||
|
@ -30,6 +32,7 @@ Squiggle lists can accept items of any type, similar to those in Python. [API](/
|
|||
/>
|
||||
|
||||
## Dictionaries
|
||||
|
||||
Squiggle dictionaries work similarly to Python dictionaries. [API](/docs/Api/Dictionary).
|
||||
|
||||
<SquiggleEditor
|
||||
|
@ -50,18 +53,23 @@ f`}
|
|||
|
||||
## Comments
|
||||
|
||||
<SquiggleEditor defaultCode={`// This is a single-line comment\n
|
||||
<SquiggleEditor
|
||||
defaultCode={`// This is a single-line comment\n
|
||||
/*
|
||||
This is a multiple
|
||||
-line comment.
|
||||
*/
|
||||
""
|
||||
`} />
|
||||
`}
|
||||
/>
|
||||
|
||||
## Pipes
|
||||
|
||||
Squiggle features [data-first](https://www.javierchavarri.com/data-first-and-data-last-a-comparison/) pipes. Functions in the standard library are organized to make this convenient.
|
||||
<SquiggleEditor defaultCode={`normal(5,2) |> truncateLeft(3) |> SampleSet.fromDist |> SampleSet.map({|r| r + 10})`} />
|
||||
|
||||
<SquiggleEditor
|
||||
defaultCode={`normal(5,2) |> truncateLeft(3) |> SampleSet.fromDist |> SampleSet.map({|r| r + 10})`}
|
||||
/>
|
||||
|
||||
## Standard Library
|
||||
|
||||
|
@ -70,24 +78,30 @@ Squiggle features a simple [standard libary](/docs/Api/Dist).
|
|||
Most functions are namespaced under their respective types to keep functionality distinct. Certain popular functions are usable without their namespaces.
|
||||
|
||||
For example,
|
||||
<SquiggleEditor defaultCode={`a = List.upTo(0, 5000) |> SampleSet.fromList // namespaces required
|
||||
|
||||
<SquiggleEditor
|
||||
defaultCode={`a = List.upTo(0, 5000) |> SampleSet.fromList // namespaces required
|
||||
b = normal(5,2) // namespace not required
|
||||
c = 5 to 10 // namespace not required
|
||||
""`} />
|
||||
""`}
|
||||
/>
|
||||
|
||||
## Number Prefixes
|
||||
|
||||
Numbers support a few scientific notation prefixes.
|
||||
|
||||
| prefix | multiplier |
|
||||
|-----|-------|
|
||||
| n | 10^-9 |
|
||||
| m | 10^-3 |
|
||||
| k | 10^3 |
|
||||
| M | 10^6 |
|
||||
| B,G | 10^9 |
|
||||
| T | 10^12 |
|
||||
| P | 10^15 |
|
||||
| prefix | multiplier |
|
||||
| ------ | ---------- |
|
||||
| n | 10^-9 |
|
||||
| m | 10^-3 |
|
||||
| k | 10^3 |
|
||||
| M | 10^6 |
|
||||
| B,G | 10^9 |
|
||||
| T | 10^12 |
|
||||
| P | 10^15 |
|
||||
|
||||
<SquiggleEditor defaultCode={`simpleNumber = 4.32k
|
||||
<SquiggleEditor
|
||||
defaultCode={`simpleNumber = 4.32k
|
||||
distribution = 40M to 50M
|
||||
distribution`} />
|
||||
distribution`}
|
||||
/>
|
||||
|
|
|
@ -10,10 +10,12 @@ Squiggle is a minimalist programming language for probabilistic estimation. It's
|
|||
The basics of Squiggle are fairly straightforward. This can be enough for many models. The more advanced functionality can take some time to learn.
|
||||
|
||||
## Simple example
|
||||
|
||||
Say you're trying to estimate the number of piano tuners in New York City. You can build a simple model of this, like so.
|
||||
(Tip: This is interactive! Feel free to modify the code directly.)
|
||||
|
||||
<SquiggleEditor defaultCode={`
|
||||
<SquiggleEditor
|
||||
defaultCode={`
|
||||
// Piano tuners in NYC over the next 5 years
|
||||
populationOfNewYork2022 = 8.1M to 8.4M // This means that you're 90% confident the value is between 8.1 and 8.4 Million.\n
|
||||
proportionOfPopulationWithPianos = {
|
||||
|
@ -26,13 +28,15 @@ pianoTunersPerPiano = {
|
|||
} \n
|
||||
totalTunersIn2022 = populationOfNewYork2022 * proportionOfPopulationWithPianos * pianoTunersPerPiano
|
||||
totalTunersIn2022
|
||||
`} />
|
||||
`}
|
||||
/>
|
||||
|
||||
---
|
||||
|
||||
Now let's take this a bit further. Let's imagine that you think that NYC will grow over time, and you'd like to estimate the number of piano tuners for every point in time for the next few years.
|
||||
|
||||
<SquiggleEditor defaultCode={`// Piano tuners in NYC over the next 5 years
|
||||
<SquiggleEditor
|
||||
defaultCode={`// Piano tuners in NYC over the next 5 years
|
||||
populationOfNewYork2022 = 8.1M to 8.4M\n
|
||||
proportionOfPopulationWithPianos = {
|
||||
percentage = (.2 to 1)
|
||||
|
@ -52,13 +56,13 @@ totalTunersAtTime(t) = populationAtTime(t) * proportionOfPopulationWithPianos *
|
|||
{
|
||||
populationAtTime: populationAtTime,
|
||||
totalTunersAtTimeMedian: {|t| median(totalTunersAtTime(t))}
|
||||
}`} />
|
||||
}`}
|
||||
/>
|
||||
|
||||
If you haven't noticed yet, you can hover over the `populationAtTime` graph to see the distribution of population at different points in time.
|
||||
|
||||
|
||||
|
||||
## Using Squiggle
|
||||
|
||||
You can currently interact with Squiggle in a few ways:
|
||||
|
||||
**[Playground](/playground)**
|
||||
|
@ -93,6 +97,7 @@ You can use Squiggle Components in Observable notebooks. Sam Nolan put together
|
|||
- A visually-driven tool. (See [Guesstimate](https://www.getguesstimate.com/) and [Causal](https://causal.app/))
|
||||
|
||||
### Strengths
|
||||
|
||||
- Simple and readable syntax, especially for dealing with probabilistic math.
|
||||
- Fast for relatively small models. Strong for rapid prototyping.
|
||||
- Optimized for using some numeric and symbolic approaches, not just Monte Carlo.
|
||||
|
@ -100,6 +105,7 @@ You can use Squiggle Components in Observable notebooks. Sam Nolan put together
|
|||
- Free and open-source.
|
||||
|
||||
### Weaknesses
|
||||
|
||||
- Limited scientific capabilities.
|
||||
- Much slower than serious probabilistic programming languages on sizeable models.
|
||||
- Can't do Bayesian backwards inference.
|
||||
|
@ -109,4 +115,5 @@ You can use Squiggle Components in Observable notebooks. Sam Nolan put together
|
|||
- Generally not as easy to use as Guesstimate or Causal, especially for non programmers.
|
||||
|
||||
## Organization
|
||||
|
||||
Squiggle is one of the main projects of [The Quantified Uncertainty Research Institute](https://quantifieduncertainty.org/). QURI is a nonprofit funded primarily by [Effective Altruist](https://www.effectivealtruism.org/) donors.
|
|
@ -10,12 +10,12 @@ function HomepageHeader() {
|
|||
return (
|
||||
<header className={clsx("hero hero--primary", styles.heroBanner)}>
|
||||
<div className="container">
|
||||
<img
|
||||
alt={'Docusaurus with Keytar'}
|
||||
className={styles.heroLogo}
|
||||
src={'/img/squiggle-logo.png'}
|
||||
width="70"
|
||||
/>
|
||||
<img
|
||||
alt={"Docusaurus with Keytar"}
|
||||
className={styles.heroLogo}
|
||||
src={"/img/squiggle-logo.png"}
|
||||
width="70"
|
||||
/>
|
||||
<h1 className="hero__title">{siteConfig.title}</h1>
|
||||
<p className="hero__subtitle">Early Access</p>
|
||||
<p className="hero__subtitle2">{siteConfig.tagline}</p>
|
||||
|
|
Loading…
Reference in New Issue
Block a user