Basic Types
Basic types supported by Squiggle
Numbers
Squiggle numbers are built directly on Javascript numbers. They can be integers or floats, and support all the usual arithmetic operations.
Number API
Numbers support a few scientific notation suffixes.
Suffix | Multiplier |
---|---|
n | 10^-9 |
m | 10^-3 |
% | 10^-2 |
k | 10^3 |
M | 10^6 |
B,G | 10^9 |
T | 10^12 |
P | 10^15 |
There's no difference between floats and integers in Squiggle.
Booleans
Booleans can be true
or false
.
Strings
Strings can be created with either single or double quotes.
String API
Distributions
Distributions are first-class citizens. Use the syntax a to b
to create a quick lognormal distribution, or write out the whole distribution name.
See these pages for more information on distributions:
There are 3 internal representation formats for distributions: Sample Set, Point Set, and Symbolic. By default, Squiggle will use sample set distributions, which allow for correlations between parameters. Point Set and Symbolic distributions will be more accurate and fast, but do not support correlations. If you prefer this tradeoff, you can manually use them by adding a Sym.
before the distribution name, i.e. Sym.normal(0, 1)
.
Lists
Squiggle lists can contain items of any type, similar to lists in Python. You can access individual list elements with [number]
notation, starting from 0
.
Squiggle is an immutable language, so you cannot modify lists in-place. Instead, you can use functions such as List.map
or List.reduce
to create new lists.
List API
Dictionaries
Squiggle dictionaries work similarly to Python dictionaries or Javascript objects. Like lists, they can contain values of any type. Keys must be strings.
Dictionary API
Other types
Other Squiggle types include: