Run prettier on website code

This commit is contained in:
Sam Nolan 2022-04-11 09:15:46 +10:00
parent 79ac1700d1
commit efb0f5e05a
20 changed files with 371 additions and 306 deletions

View File

@ -0,0 +1 @@
.docusaurus

View File

@ -6,23 +6,26 @@ This website is built using [Docusaurus 2](https://docusaurus.io/), a modern sta
This one actually works without running `yarn` at the monorepo level, but it doesn't hurt. You must at least run it at this package level This one actually works without running `yarn` at the monorepo level, but it doesn't hurt. You must at least run it at this package level
``` sh ```sh
yarn yarn
``` ```
This command generates static content into the `build` directory and can be served using any static contents hosting service. This command generates static content into the `build` directory and can be served using any static contents hosting service.
``` sh
```sh
yarn build yarn build
``` ```
Your local dev server is here, opening up a browser window. Your local dev server is here, opening up a browser window.
``` sh
```sh
yarn start yarn start
``` ```
Most changes are reflected live without having to restart the server. Most changes are reflected live without having to restart the server.
Clean up the build artefacts. Clean up the build artefacts.
``` sh
```sh
yarn clean yarn clean
``` ```

View File

@ -1,6 +1,6 @@
module.exports = { module.exports = {
presets: [ presets: [
require.resolve('@docusaurus/core/lib/babel/preset'), require.resolve("@docusaurus/core/lib/babel/preset"),
["@babel/preset-react", { "runtime": "automatic" }] ["@babel/preset-react", { runtime: "automatic" }],
], ],
}; };

View File

@ -5,9 +5,10 @@ authors: ozzie
--- ---
# Multivariate estimation & the Squiggly language # Multivariate estimation & the Squiggly language
*This post was originally published on Aug 2020, on [LessWrong](https://www.lesswrong.com/posts/g9QdXySpydd6p8tcN/sunday-august-16-12pm-pdt-talks-by-ozzie-gooen-habryka-ben). The name of the project has since been changed from Suiggly to Squiggle*
*(Talk given at the LessWrong Lighting Talks in 2020. Ozzie Gooen is responsible for the talk, Jacob Lagerros and Justis Mills edited the transcript.* [an event on Sunday 16th of August](https://www.lesswrong.com/posts/g9QdXySpydd6p8tcN/sunday-august-16-12pm-pdt-talks-by-ozzie-gooen-habryka-ben)) _This post was originally published on Aug 2020, on [LessWrong](https://www.lesswrong.com/posts/g9QdXySpydd6p8tcN/sunday-august-16-12pm-pdt-talks-by-ozzie-gooen-habryka-ben). The name of the project has since been changed from Suiggly to Squiggle_
_(Talk given at the LessWrong Lighting Talks in 2020. Ozzie Gooen is responsible for the talk, Jacob Lagerros and Justis Mills edited the transcript._ [an event on Sunday 16th of August](https://www.lesswrong.com/posts/g9QdXySpydd6p8tcN/sunday-august-16-12pm-pdt-talks-by-ozzie-gooen-habryka-ben))
![](https://lh5.googleusercontent.com/ebsMFHLu-qE2ZABLhk8aWYx9SqfswabLWxpZKr0iq5PSsv1ruQnRwcDGUzryILT3GuXqL1w1WZARv6Zbjq-o8I4xS0yErm_JHihDYMScY65xLsYgy4svUzI3E6mmBoVTO9IZg4Sv) ![](https://lh5.googleusercontent.com/ebsMFHLu-qE2ZABLhk8aWYx9SqfswabLWxpZKr0iq5PSsv1ruQnRwcDGUzryILT3GuXqL1w1WZARv6Zbjq-o8I4xS0yErm_JHihDYMScY65xLsYgy4svUzI3E6mmBoVTO9IZg4Sv)
**Ozzie:** This image is my [TLDR](https://en.wikipedia.org/wiki/Wikipedia:Too_long;_didn%27t_read) on probability distributions: **Ozzie:** This image is my [TLDR](https://en.wikipedia.org/wiki/Wikipedia:Too_long;_didn%27t_read) on probability distributions:
@ -49,16 +50,17 @@ So that's why I've been working on the Squiggly language.
Lets look at some quick examples! Lets look at some quick examples!
![](https://lh6.googleusercontent.com/bis1Gdsp9jx4o36j_vBjE7NEYc5xKud9K1yjnv2K2YbFB5UhFAsR0uDjgGXMlKqg99fNVMTrIBj1YDuRVh5cxwPZ1QYum8JMujhQxnH-1JQDbH9BKtQ9mA5BdwCzx8LC_l6RtvgE) ![](https://lh6.googleusercontent.com/bis1Gdsp9jx4o36j_vBjE7NEYc5xKud9K1yjnv2K2YbFB5UhFAsR0uDjgGXMlKqg99fNVMTrIBj1YDuRVh5cxwPZ1QYum8JMujhQxnH-1JQDbH9BKtQ9mA5BdwCzx8LC_l6RtvgE)
This is a classic normal distribution, but once you have this, some of the challenge is making it as easy as possible to make functions that return distributions. This is a classic normal distribution, but once you have this, some of the challenge is making it as easy as possible to make functions that return distributions.
Here's a case for any *t*: Here's a case for any _t_:
![](https://lh4.googleusercontent.com/QZr0XwYQNmilOhboJXGT3J2Gpt9X7W9aifA_E1PorGeKPjKF3XYOXrhRcn38xh4KKwA6TEDXoF5B9C78MBIAJ6mO7E9tS4_9-jwh1eKlp9wYkc_StUXsi4KRwC8nhBoVXm3lZbis) ![](https://lh4.googleusercontent.com/QZr0XwYQNmilOhboJXGT3J2Gpt9X7W9aifA_E1PorGeKPjKF3XYOXrhRcn38xh4KKwA6TEDXoF5B9C78MBIAJ6mO7E9tS4_9-jwh1eKlp9wYkc_StUXsi4KRwC8nhBoVXm3lZbis)
We're going to give you a normal, with *t* as a mean and the standard deviation of 3. This is a plot where it's basically showing bars at each one of the deciles. It gets a bit wider at the end. It's very easy once you have this to just create it for any specific combination of values. We're going to give you a normal, with _t_ as a mean and the standard deviation of 3. This is a plot where it's basically showing bars at each one of the deciles. It gets a bit wider at the end. It's very easy once you have this to just create it for any specific combination of values.
Its also cool, because once you have it in this format, its very easy to combine multiple models. For instance, heres a lognormal. Its also cool, because once you have it in this format, its very easy to combine multiple models. For instance, heres a lognormal.
![](https://lh6.googleusercontent.com/g4dYJBmu6ScK9CePMAu_6h9u2PRbRScQlLy_0uKWLmMAOPgJXLp4IXGCUOigCmKetxXtfcpQHLb9Rilkch4FMPV94bZ_MaNWpBSfDYsR0ll4dYdedmkdjwQ1M5FhIa891fu53Hcf) ![](https://lh6.googleusercontent.com/g4dYJBmu6ScK9CePMAu_6h9u2PRbRScQlLy_0uKWLmMAOPgJXLp4IXGCUOigCmKetxXtfcpQHLb9Rilkch4FMPV94bZ_MaNWpBSfDYsR0ll4dYdedmkdjwQ1M5FhIa891fu53Hcf)
For example, if I have an estimate and my friend Jacob has an estimate, then we could write a function that for every time *t*, basically queries each one of our estimates and gives that as a combined result. For example, if I have an estimate and my friend Jacob has an estimate, then we could write a function that for every time _t_, basically queries each one of our estimates and gives that as a combined result.
This kind of shows you a problem with fan charts, that they dont show the fact that all the probability amasses on the very top and the very bottom. Thats an issue that well get over soon. Heres what it looks like if I aggregate my model with Jacobs. This kind of shows you a problem with fan charts, that they dont show the fact that all the probability amasses on the very top and the very bottom. Thats an issue that well get over soon. Heres what it looks like if I aggregate my model with Jacobs.
![](https://lh3.googleusercontent.com/mG50mXS2kUXx9mhBksx39s-GgY-yBs0HT4Acl2KAUba-WZ---aSOUONzvrtxYr9q__dLbf7vKzg_TVe7rKJH4c8sHPdM2k4Wi0p_FfQJr_UYzFexee6p9tfigHicmPI0NZw9ggXC) ![](https://lh3.googleusercontent.com/mG50mXS2kUXx9mhBksx39s-GgY-yBs0HT4Acl2KAUba-WZ---aSOUONzvrtxYr9q__dLbf7vKzg_TVe7rKJH4c8sHPdM2k4Wi0p_FfQJr_UYzFexee6p9tfigHicmPI0NZw9ggXC)
## Questions ## Questions
**Raemon:** **Raemon:**
I had a little bit of excitement, and then fear, and then excitement again, when you talked about a unified format. The excitement was like, “Ah, a unified format, that sounds nice.” Then I had an image of all of the giant coordination problems that result from failed attempts to create a new unified format, where the attempted unified format becomes [yet another distinct format](https://xkcd.com/927/) among all the preexisting options. I had a little bit of excitement, and then fear, and then excitement again, when you talked about a unified format. The excitement was like, “Ah, a unified format, that sounds nice.” Then I had an image of all of the giant coordination problems that result from failed attempts to create a new unified format, where the attempted unified format becomes [yet another distinct format](https://xkcd.com/927/) among all the preexisting options.
@ -75,7 +77,8 @@ Yeah, you can build the thing that seems good for you. That seems good. If you g
**Ozzie:** **Ozzie:**
Yeah. Right now, Im aiming for something thats good at a bunch of things but not that great at any one of them. Im also very curious to get outside opinions. Hopefully people could start playing with this, and I can get their thoughts. Yeah. Right now, Im aiming for something thats good at a bunch of things but not that great at any one of them. Im also very curious to get outside opinions. Hopefully people could start playing with this, and I can get their thoughts.
- - - - ---
**habryka:** **habryka:**
This feels very similar to [Guesstimate](https://www.getguesstimate.com/) , which you also built, just in programming language as opposed to visual language. How does this project differ? This feels very similar to [Guesstimate](https://www.getguesstimate.com/) , which you also built, just in programming language as opposed to visual language. How does this project differ?
@ -86,7 +89,8 @@ Really, a lot of Squiggly is me trying to remake for my sins with Guesstimate. W
So I think these new features are pretty fundamental. I think that this is a pretty big step in the right direction. In general text-based solutions have a lot of benefits when you can use them, but it is kind of tricky to use them. So I think these new features are pretty fundamental. I think that this is a pretty big step in the right direction. In general text-based solutions have a lot of benefits when you can use them, but it is kind of tricky to use them.
- - - - ---
**Johnswentworth:** **Johnswentworth:**
Im getting sort of mixed vibes about what exactly the use case here is. If were thinking of this as a sort of standard for representing models, then I should be able to convert models in other formats, right? Like, if I have a model in Excel or I have a model in [Pyro](https://pyro.ai/) , then there should be some easy way to turn it into this standard format? Im getting sort of mixed vibes about what exactly the use case here is. If were thinking of this as a sort of standard for representing models, then I should be able to convert models in other formats, right? Like, if I have a model in Excel or I have a model in [Pyro](https://pyro.ai/) , then there should be some easy way to turn it into this standard format?
@ -112,7 +116,7 @@ Its complicated. If you made your model in Pyro and you wanted to then export
Why would people run that though? Why do people want that compressed model? Why would people run that though? Why do people want that compressed model?
**Ozzie:** **Ozzie:**
I mean, a lot of the COVID models are like that, where basically the *running* of the simulation was very time intensive and required one persons whole PC. But it would still be nice to be able to export the *results*of that and then make those interactable, right? I mean, a lot of the COVID models are like that, where basically the _running_ of the simulation was very time intensive and required one persons whole PC. But it would still be nice to be able to export the *results*of that and then make those interactable, right?
**Johnswentworth:** **Johnswentworth:**
Oh, I see. Okay, I buy that. Oh, I see. Okay, I buy that.
@ -123,9 +127,10 @@ I also dont want to have to write all of the work to do all of the Pyro stuff
**Johnswentworth:** **Johnswentworth:**
Usually, when Im thinking about this sort of thing, and I look at someones model, I really want to know what the underlying gears were behind it. Which is exactly the opposite of what youre talking about. So its just a use case that Im not used to thinking through. But I agree, it does make sense. Usually, when Im thinking about this sort of thing, and I look at someones model, I really want to know what the underlying gears were behind it. Which is exactly the opposite of what youre talking about. So its just a use case that Im not used to thinking through. But I agree, it does make sense.
- - - - ---
**habryka:** **habryka:**
Why call the language Squiggly? There were a surprising lack of squiggles in the language. I was like, “Ah, it makes sense, you just use the squiggles as the primary abstraction” — but then you showed me your code editor and there were no squiggles, and I was very disappointed. Why call the language Squiggly? There were a surprising lack of squiggles in the language. I was like, “Ah, it makes sense, you just use the squiggles as the primary abstraction” — but then you showed me your code editor and there were no squiggles, and I was very disappointed.
**Ozzie:** **Ozzie:**
Yeah, so I havent written my own parser yet. Ive been using the one from math.js. When I write my own, its possible Ill add it. I also am just really unsure about the name. Yeah, so I havent written my own parser yet. Ive been using the one from math.js. When I write my own, its possible Ill add it. I also am just really unsure about the name.

View File

@ -3,24 +3,30 @@ slug: technical-overview
title: Technical Overview title: Technical Overview
authors: ozzie authors: ozzie
--- ---
# Squiggle Technical Overview # Squiggle Technical Overview
This piece is meant to be read after [Squiggle: An Overview](https://www.lesswrong.com/posts/i5BWqSzuLbpTSoTc4/squiggle-an-overview) . It includes technical information I thought best separated out for readers familiar with coding. As such, its a bit of a grab-bag. It explains the basic internals of Squiggle, outlines ways it could be used in other programming languages, and details some of the history behind it. This piece is meant to be read after [Squiggle: An Overview](https://www.lesswrong.com/posts/i5BWqSzuLbpTSoTc4/squiggle-an-overview) . It includes technical information I thought best separated out for readers familiar with coding. As such, its a bit of a grab-bag. It explains the basic internals of Squiggle, outlines ways it could be used in other programming languages, and details some of the history behind it.
The Squiggle codebase is organized in [this github repo](https://github.com/foretold-app/squiggle) . Its open source. The code is quite messy now, but do ping me if youre interested in running it or understanding it. The Squiggle codebase is organized in [this github repo](https://github.com/foretold-app/squiggle) . Its open source. The code is quite messy now, but do ping me if youre interested in running it or understanding it.
## Project Subcomponents ## Project Subcomponents
I think of Squiggle in three distinct clusters. I think of Squiggle in three distinct clusters.
1. A high-level ReasonML library for probability distributions. 1. A high-level ReasonML library for probability distributions.
2. A simple programming language. 2. A simple programming language.
3. Custom visualizations and GUIs. 3. Custom visualizations and GUIs.
### 1. A high-level ReasonML library for probability distribution functions ### 1. A high-level ReasonML library for probability distribution functions
Python has some great libraries for working with probabilities and symbolic mathematics. Javascript doesnt. Squiggle is to be run in Javascript (for interactive editing and use), so the first step for this is to have good libraries to do the basic math. Python has some great libraries for working with probabilities and symbolic mathematics. Javascript doesnt. Squiggle is to be run in Javascript (for interactive editing and use), so the first step for this is to have good libraries to do the basic math.
The second step is to have-level types that could express various types of distributions and functions of distributions. For example, some distributions have symbolic representations, and others are rendered (stored as x-y coordinates). These two types have to be dealt with separately. Squiggle also has limited support for continuous and discrete mixtures, and the math for this adds more complexity. The second step is to have-level types that could express various types of distributions and functions of distributions. For example, some distributions have symbolic representations, and others are rendered (stored as x-y coordinates). These two types have to be dealt with separately. Squiggle also has limited support for continuous and discrete mixtures, and the math for this adds more complexity.
When it comes to performing functions on expressions, theres a lot of optimization necessary for this to go smoothly. When it comes to performing functions on expressions, theres a lot of optimization necessary for this to go smoothly.
Say you were to write the function, Say you were to write the function,
``` ```
multimodal(normal(5,2), normal(10,1) + uniform(1,10)) * 100 multimodal(normal(5,2), normal(10,1) + uniform(1,10)) * 100
``` ```
@ -30,6 +36,7 @@ Youd want to apply a combination of symbolic, numeric, and sampling technique
This type-dependent function operations can be confusing to users, but hopefully less confusing than having to figure out how to do each of the three and doing them separately. I imagine there could be some debugging UI to better explain what operations are performed. This type-dependent function operations can be confusing to users, but hopefully less confusing than having to figure out how to do each of the three and doing them separately. I imagine there could be some debugging UI to better explain what operations are performed.
### 2. Simple programming language functionality ### 2. Simple programming language functionality
It can be useful to think of Squiggle as similar to SQL, Excel, or Probabilistic Programming Languages like [WebPPL](http://webppl.org/) . There are simple ways to declare variables and write functions, but dont expect to use classes, inheritance, or monads. Theres no for loops, though it will probably have some kinds of reduce() methods in the future. It can be useful to think of Squiggle as similar to SQL, Excel, or Probabilistic Programming Languages like [WebPPL](http://webppl.org/) . There are simple ways to declare variables and write functions, but dont expect to use classes, inheritance, or monads. Theres no for loops, though it will probably have some kinds of reduce() methods in the future.
So far the parsing is done with MathJS, meaning we cant change the syntax. Im looking forward to doing so and have been thinking about what it should be like. One idea Im aiming for is to allow for simple dependent typing for the sake of expressing limited functions. For instance, So far the parsing is done with MathJS, meaning we cant change the syntax. Im looking forward to doing so and have been thinking about what it should be like. One idea Im aiming for is to allow for simple dependent typing for the sake of expressing limited functions. For instance,
@ -44,6 +51,7 @@ This function would return an error if called with a float less than 0 or greate
With some introspection it should be possible to auto-generate calculator-like interfaces. With some introspection it should be possible to auto-generate calculator-like interfaces.
### 3. Visualizations and GUIs ### 3. Visualizations and GUIs
The main visualizations need to be made from scratch because theres little out there now in terms of quality open-source visualizations of probability distributions and similar. This is especially true for continuous and discrete mixtures. D3 seems like the main library here, and D3 can be gnarly to write and maintain. The main visualizations need to be made from scratch because theres little out there now in terms of quality open-source visualizations of probability distributions and similar. This is especially true for continuous and discrete mixtures. D3 seems like the main library here, and D3 can be gnarly to write and maintain.
Right now were using a basic [Vega](https://vega.github.io/) chart for the distribution over a variable, but this will be replaced later. Right now were using a basic [Vega](https://vega.github.io/) chart for the distribution over a variable, but this will be replaced later.
@ -51,6 +59,7 @@ Right now were using a basic [Vega](https://vega.github.io/) chart for the
In the near term, Im interested in making calculator-like user interfaces of various kinds. I imagine one prediction function could be used for many interfaces of calculators. In the near term, Im interested in making calculator-like user interfaces of various kinds. I imagine one prediction function could be used for many interfaces of calculators.
## Deployment Story, or, Why Javascript? ## Deployment Story, or, Why Javascript?
Squiggle is written in ReasonML which compiles to Javascript. The obvious alternative is Python. Lesser obvious but interesting options are Mathematica or Rust via WebAssembly. Squiggle is written in ReasonML which compiles to Javascript. The obvious alternative is Python. Lesser obvious but interesting options are Mathematica or Rust via WebAssembly.
The plan for Squiggle is to prioritize small programs that could be embedded in other programs and run quickly. Perhaps there will be 30 submissions for a “Covid-19 over time per location” calculator, and wed want to run them in parallel in order to find the average answer or to rank them. I could imagine many situations where it would be useful to run these functions for many different inputs; for example, for kinds of sensitivity analyses. The plan for Squiggle is to prioritize small programs that could be embedded in other programs and run quickly. Perhaps there will be 30 submissions for a “Covid-19 over time per location” calculator, and wed want to run them in parallel in order to find the average answer or to rank them. I could imagine many situations where it would be useful to run these functions for many different inputs; for example, for kinds of sensitivity analyses.
@ -76,11 +85,13 @@ ReasonML compiles to OCaml before it compiles to Javascript. Ive found it con
I imagine the landscape will change a lot in the next 3 to 10 years. Im going to continue to keep an eye on the space. If things change I could very much imagine pursuing a rewrite, but I think it will be a while before any change seems obvious. I imagine the landscape will change a lot in the next 3 to 10 years. Im going to continue to keep an eye on the space. If things change I could very much imagine pursuing a rewrite, but I think it will be a while before any change seems obvious.
## Using Squiggle with other languages ## Using Squiggle with other languages
Once the basics of Squiggle are set up, it could be used to describe the results of models that come from other programs. Similar to how many programming languages have ORMs to generate custom SQL statements, similar tools could be made to generate Squiggle functions. The important thing to grok is that Squiggle functions are submitted information, not just internally useful tools. If there were an API to accept “predictions”, people would submit Squiggle code snippets directly to this API. Once the basics of Squiggle are set up, it could be used to describe the results of models that come from other programs. Similar to how many programming languages have ORMs to generate custom SQL statements, similar tools could be made to generate Squiggle functions. The important thing to grok is that Squiggle functions are submitted information, not just internally useful tools. If there were an API to accept “predictions”, people would submit Squiggle code snippets directly to this API.
*Id note here that I find it somewhat interesting how few public APIs do accept code snippets. I could imagine a version of Facebook where you could submit a Javascript function that would take in information about a post and return a number that would be used for ranking it in your feed. This kind of functionality seems like it could be very powerful. My impression is that its currently thought to be too hard to do given existing technologies. This of course is not a good sign for the feasibility of my proposal here, but this coarse seems like a necessary one to do at some time.* _Id note here that I find it somewhat interesting how few public APIs do accept code snippets. I could imagine a version of Facebook where you could submit a Javascript function that would take in information about a post and return a number that would be used for ranking it in your feed. This kind of functionality seems like it could be very powerful. My impression is that its currently thought to be too hard to do given existing technologies. This of course is not a good sign for the feasibility of my proposal here, but this coarse seems like a necessary one to do at some time._
### Example #1: ### Example #1:
Say you calculate a few parameters, but know they represent a multimodal combination of a normal distribution and a uniform distribution. You want to submit that as your prediction or estimate via the API of Metaculus or Foretold. You could write that as (in Javascript): Say you calculate a few parameters, but know they represent a multimodal combination of a normal distribution and a uniform distribution. You want to submit that as your prediction or estimate via the API of Metaculus or Foretold. You could write that as (in Javascript):
``` ```
@ -92,6 +103,7 @@ The alternative to this is that you send a bunch of X-Y coordinates representing
With Squiggle, you dont need to calculate the shape of the function in your code, you just need to express it symbolically and send that off. With Squiggle, you dont need to calculate the shape of the function in your code, you just need to express it symbolically and send that off.
### Example #2: ### Example #2:
Say you want to describe a distribution with a few or a bunch of calculated CDF points. You could do this by wrapping these points into a function that would convert them into a smooth distribution using one of several possible interpolation methods. Maybe in Javascript this would be something like, Say you want to describe a distribution with a few or a bunch of calculated CDF points. You could do this by wrapping these points into a function that would convert them into a smooth distribution using one of several possible interpolation methods. Maybe in Javascript this would be something like,
``` ```
@ -102,6 +114,7 @@ var squiggleValue = `interpolatePoints(${points}, metalog)`
I could imagine it is possible that the majority of distributions generated from other code would be sent this way. However, I cant tell what the specifics of that now or what interpolation strategies may be favored. Doing it with many options would allow us to wait and learn what seems to be best. If there is one syntax used an overwhelming proportion of the time, perhaps that could be separated into its own simpler format. I could imagine it is possible that the majority of distributions generated from other code would be sent this way. However, I cant tell what the specifics of that now or what interpolation strategies may be favored. Doing it with many options would allow us to wait and learn what seems to be best. If there is one syntax used an overwhelming proportion of the time, perhaps that could be separated into its own simpler format.
### Example #3: ### Example #3:
Say you want to estimate Tesla stock at every point in the next 10 years. You decide to estimate this using a simple analytical equation, where you predict that the price of Tesla stock can be modeled as growing by a mean of -3 to 8 percent each year from the current price using a normal distribution (apologies to Nassim Taleb). Say you want to estimate Tesla stock at every point in the next 10 years. You decide to estimate this using a simple analytical equation, where you predict that the price of Tesla stock can be modeled as growing by a mean of -3 to 8 percent each year from the current price using a normal distribution (apologies to Nassim Taleb).
You have a script that fetches Teslas current stock, then uses that in the following string template: You have a script that fetches Teslas current stock, then uses that in the following string template:
@ -113,6 +126,7 @@ var squiggleValue = `(t) => ${current_price} * (0.97 to 1.08)^t`
It may seem a bit silly to not just fetch Teslas price from within Squiggle, but it does help separate concerns. Data fetching within Squiggle would raise a bunch of issues, especially when trying to score Squiggle functions.It may seem a bit silly to not just fetch Teslas price from within Squiggle, but it does help separate concerns. Data fetching within Squiggle would raise a bunch of issues, especially when trying to score Squiggle functions. It may seem a bit silly to not just fetch Teslas price from within Squiggle, but it does help separate concerns. Data fetching within Squiggle would raise a bunch of issues, especially when trying to score Squiggle functions.It may seem a bit silly to not just fetch Teslas price from within Squiggle, but it does help separate concerns. Data fetching within Squiggle would raise a bunch of issues, especially when trying to score Squiggle functions.
## History: From Guesstimate to Squiggle ## History: From Guesstimate to Squiggle
The history of “Squiggle” goes back to early Guesstimate. Its been quite a meandering journey. I was never really expecting things to go the particular way they did, but at least am relatively satisfied with how things are right now. I imagine these details wont be interesting to most readers, but wanted to include it for those particularly close to the project, or for those curious on what I personally have been up to. The history of “Squiggle” goes back to early Guesstimate. Its been quite a meandering journey. I was never really expecting things to go the particular way they did, but at least am relatively satisfied with how things are right now. I imagine these details wont be interesting to most readers, but wanted to include it for those particularly close to the project, or for those curious on what I personally have been up to.
90% of the work on Squiggle has been on a probability distribution editor (“A high-level ReasonML library for probability distribution functions**”)**. This has been a several year process, including my time with Guesstimate. The other 10% of the work, with the custom functions, is much more recent. 90% of the work on Squiggle has been on a probability distribution editor (“A high-level ReasonML library for probability distribution functions**”)**. This has been a several year process, including my time with Guesstimate. The other 10% of the work, with the custom functions, is much more recent.
@ -128,11 +142,13 @@ Limited distribution editors like those in Metaculus or Elicit dont use sampl
It took a while, but we eventually created a simple editor that would use numeric techniques to combine a small subset of distributions and functions using a semi-flexible string representation. If users would request functionality not available in this editor (like multiplying two distributions together, which would require sampling), it would fall back to using the old editor. This was useful but suboptimal. It required us to keep two versions of the editor with slightly different syntaxes, which was not fun for users to keep track of. It took a while, but we eventually created a simple editor that would use numeric techniques to combine a small subset of distributions and functions using a semi-flexible string representation. If users would request functionality not available in this editor (like multiplying two distributions together, which would require sampling), it would fall back to using the old editor. This was useful but suboptimal. It required us to keep two versions of the editor with slightly different syntaxes, which was not fun for users to keep track of.
The numeric solver could figure out syntaxes like, The numeric solver could figure out syntaxes like,
``` ```
multimodal(normal(5,2), uniform(10,13), [.2,.8]) multimodal(normal(5,2), uniform(10,13), [.2,.8])
``` ```
But would break anytime you wanted to use any other function, like, But would break anytime you wanted to use any other function, like,
``` ```
multimodal(normal(5,2) + lognormal(1,1.5), uniform(10,13), [.2,.8])*100 multimodal(normal(5,2) + lognormal(1,1.5), uniform(10,13), [.2,.8])*100
``` ```

View File

@ -4,9 +4,9 @@ title: Squiggle Overview
authors: ozzie authors: ozzie
--- ---
Ive spent a fair bit of time over the last several years iterating on a text-based probability distribution editor (the ``5 to 10`` input editor in Guesstimate and Foretold). Recently Ive added some programming language functionality to it, and have decided to refocus it as a domain-specific language. Ive spent a fair bit of time over the last several years iterating on a text-based probability distribution editor (the `5 to 10` input editor in Guesstimate and Foretold). Recently Ive added some programming language functionality to it, and have decided to refocus it as a domain-specific language.
The language is currently called *Squiggle*. Squiggle is made for expressing distributions and functions that return distributions. I hope that it can be used one day for submitting complex predictions on Foretold and other platforms. The language is currently called _Squiggle_. Squiggle is made for expressing distributions and functions that return distributions. I hope that it can be used one day for submitting complex predictions on Foretold and other platforms.
Right now Squiggle is very much a research endeavor. Im making significant sacrifices for stability and deployment in order to test out exciting possible features. If it were being developed in a tech company, it would be in the “research” or “labs” division. Right now Squiggle is very much a research endeavor. Im making significant sacrifices for stability and deployment in order to test out exciting possible features. If it were being developed in a tech company, it would be in the “research” or “labs” division.
@ -16,13 +16,16 @@ I expect to spend a lot of time on Squiggle in the next several months or years.
Squiggle was previously introduced in a short talk that was transcribed [here](https://www.lesswrong.com/posts/kTzADPE26xh3dyTEu/multivariate-estimation-and-the-squiggly-language) , and Nuño Sempere wrote a post about using it [here](https://www.lesswrong.com/posts/kTzADPE26xh3dyTEu/multivariate-estimation-and-the-squiggly-language) . Squiggle was previously introduced in a short talk that was transcribed [here](https://www.lesswrong.com/posts/kTzADPE26xh3dyTEu/multivariate-estimation-and-the-squiggly-language) , and Nuño Sempere wrote a post about using it [here](https://www.lesswrong.com/posts/kTzADPE26xh3dyTEu/multivariate-estimation-and-the-squiggly-language) .
*Note: the code for this has developed since my time on Guesstimate. With Guesstimate, I had one cofounder, Matthew McDermott. During the last two years, Ive had a lot of help from a handful of programmers and enthusiasts. Many thanks to Sebastian Kosch and Nuño Sempere, who both contributed. Ill refer to this vague collective as “we” throughout this post.* _Note: the code for this has developed since my time on Guesstimate. With Guesstimate, I had one cofounder, Matthew McDermott. During the last two years, Ive had a lot of help from a handful of programmers and enthusiasts. Many thanks to Sebastian Kosch and Nuño Sempere, who both contributed. Ill refer to this vague collective as “we” throughout this post._
--- ---
# Video Demo # Video Demo
<iframe width="675" height="380" src="https://www.youtube.com/embed/kJLybQWujco" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe> <iframe width="675" height="380" src="https://www.youtube.com/embed/kJLybQWujco" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
## A Quick Tour ## A Quick Tour
The syntax is forked from Guesstimate and Foretold. The syntax is forked from Guesstimate and Foretold.
**A simple normal distribution** **A simple normal distribution**
@ -30,11 +33,13 @@ The syntax is forked from Guesstimate and Foretold.
``` ```
normal(5,2) normal(5,2)
``` ```
![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/61eb60718ef462e8788ae077aff49e80561774e1917fecf8.png/w_512) ![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/61eb60718ef462e8788ae077aff49e80561774e1917fecf8.png/w_512)
You may notice that unlike Guesstimate, the distribution is nearly perfectly smooth. Its this way because it doesnt use sampling for (many) functions where it doesnt need to. You may notice that unlike Guesstimate, the distribution is nearly perfectly smooth. Its this way because it doesnt use sampling for (many) functions where it doesnt need to.
**Lognormal shorthand** **Lognormal shorthand**
``` ```
5 to 10 5 to 10
``` ```
@ -43,20 +48,20 @@ You may notice that unlike Guesstimate, the distribution is nearly perfectly smo
This results in a lognormal distribution with 5 to 10 being the 5th and 95th confidence intervals respectively. This results in a lognormal distribution with 5 to 10 being the 5th and 95th confidence intervals respectively.
You can also write lognormal distributions as: ### lognormal(1,2) You can also write lognormal distributions as: ### lognormal(1,2)
or ### lognormal({mean: 3, stdev: 8}) or ### lognormal({mean: 3, stdev: 8})
. .
**Mix distributions with the multimodal function** **Mix distributions with the multimodal function**
```multimodal(normal(5,2), uniform(14,19), [.2, .8])``` `multimodal(normal(5,2), uniform(14,19), [.2, .8])`
![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/f87a3805adb027cc7f4c42c75a82f96cf9443ba4517ac93d.png/w_1252) ![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/f87a3805adb027cc7f4c42c75a82f96cf9443ba4517ac93d.png/w_1252)
You can also use the shorthand *mm*(), and add an array at the end to represent the weights of each combined distribution. You can also use the shorthand _mm_(), and add an array at the end to represent the weights of each combined distribution.
*Note: Right now, in the demo, I believe “multimodal” is broken, but you can use “mm”.* _Note: Right now, in the demo, I believe “multimodal” is broken, but you can use “mm”._
**Mix distributions with discrete data** **Mix distributions with discrete data**
*Note: This is particularly buggy.* . _Note: This is particularly buggy._ .
``` ```
multimodal(0, 10, normal(4,5), [.4,.1, .5]) multimodal(0, 10, normal(4,5), [.4,.1, .5])
@ -65,6 +70,7 @@ multimodal(0, 10, normal(4,5), [.4,.1, .5])
![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/f87a3805adb027cc7f4c42c75a82f96cf9443ba4517ac93d.png/w_1252) ![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/f87a3805adb027cc7f4c42c75a82f96cf9443ba4517ac93d.png/w_1252)
**Variables** **Variables**
``` ```
expected_case = normal(5,2) expected_case = normal(5,2)
long_tail = 3 to 1000 long_tail = 3 to 1000
@ -73,6 +79,7 @@ multimodal(expected_case, long_tail, [.2,.8])
**Simple calculations** **Simple calculations**
When calculations are done on two distributions, and there is no trivial symbolic solution the system will use Monte Carlo sampling for these select combinations. This assumes they are perfectly independent. When calculations are done on two distributions, and there is no trivial symbolic solution the system will use Monte Carlo sampling for these select combinations. This assumes they are perfectly independent.
``` ```
multimodal(normal(5,2) + uniform(10,3), (5 to 10) + 10) * 100 multimodal(normal(5,2) + uniform(10,3), (5 to 10) + 10) * 100
``` ```
@ -81,6 +88,7 @@ multimodal(normal(5,2) + uniform(10,3), (5 to 10) + 10) * 100
**Pointwise calculations** **Pointwise calculations**
We have an infix for what can be described as pointwise distribution calculations. Calculations are done along the y-axis instead of the x-axis, so to speak. “Pointwise” multiplication is equivalent to an independent Bayesian update. After each calculation, the distributions are renormalized. We have an infix for what can be described as pointwise distribution calculations. Calculations are done along the y-axis instead of the x-axis, so to speak. “Pointwise” multiplication is equivalent to an independent Bayesian update. After each calculation, the distributions are renormalized.
``` ```
normal(10,4) .* normal(14,3) normal(10,4) .* normal(14,3)
``` ```
@ -105,18 +113,20 @@ myFunction
![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/33004fd2282ad10d42608301c4cf8cd9342351410a1e290d.png/w_1378) ![](https://39669.cdn.cke-cs.com/rQvD3VnunXZu34m86e5f/images/33004fd2282ad10d42608301c4cf8cd9342351410a1e290d.png/w_1378)
## Reasons to Focus on Functions ## Reasons to Focus on Functions
Up until recently, Squiggle didnt have function support. Going forward this will be the primary feature. Up until recently, Squiggle didnt have function support. Going forward this will be the primary feature.
Functions are useful for two distinct purposes. First, they allow composition of models. Second, they can be used directly to be submitted as predictions. For instance, in theory you could predict, “For any point in time T, and company N, from now until 2050, this function will predict the market cap of the company.” Functions are useful for two distinct purposes. First, they allow composition of models. Second, they can be used directly to be submitted as predictions. For instance, in theory you could predict, “For any point in time T, and company N, from now until 2050, this function will predict the market cap of the company.”
At this point Im convinced of a few things: At this point Im convinced of a few things:
* Its possible to intuitively write distributions and functions that return distributions, with the right tooling.
* Functions that return distributions are highly preferable to specific distributions, if possible. - Its possible to intuitively write distributions and functions that return distributions, with the right tooling.
* It would also be great if existing forecasting models could be distilled into common formats. - Functions that return distributions are highly preferable to specific distributions, if possible.
* Theres very little activity in this space now. - It would also be great if existing forecasting models could be distilled into common formats.
* Theres a high amount of value of information to further exploring the space. - Theres very little activity in this space now.
* Writing a small DSL like this will be a fair bit of work, but can be feasible if the functionality is kept limited. - Theres a high amount of value of information to further exploring the space.
* Also, there are several other useful aspects about having a simple language equivalent for Guesstimate style models. - Writing a small DSL like this will be a fair bit of work, but can be feasible if the functionality is kept limited.
- Also, there are several other useful aspects about having a simple language equivalent for Guesstimate style models.
I think that this is a highly neglected area and Im surprised it hasnt been explored more. Its possible that doing a good job is too challenging for a small team, but I think its worth investigating further. I think that this is a highly neglected area and Im surprised it hasnt been explored more. Its possible that doing a good job is too challenging for a small team, but I think its worth investigating further.
@ -137,20 +147,24 @@ One analogy is to think about the online estimation “calculators” and “mod
If they were to use a hypothetical front end unified format, this would mean converting their results into a Javascript function that could be called using a standardized interface. This standardization would make it easier for these calculators to be called by third party wigets and UIs, or for them to be downloaded and called from other workflows. The priority here is that the calculators could be run quickly and that the necessary code and data is minimized in size. Heavy calculation and analysis would still happen separately. If they were to use a hypothetical front end unified format, this would mean converting their results into a Javascript function that could be called using a standardized interface. This standardization would make it easier for these calculators to be called by third party wigets and UIs, or for them to be downloaded and called from other workflows. The priority here is that the calculators could be run quickly and that the necessary code and data is minimized in size. Heavy calculation and analysis would still happen separately.
### Future “Comprehensive” Uses ### Future “Comprehensive” Uses
On the more comprehensive end, it would be interesting to figure out how individuals or collectives could make large clusters of these functions, where many functions call other functions, and continuous data is pulled in. The latter would probably require some server/database setup that ingests Squiggle files. On the more comprehensive end, it would be interesting to figure out how individuals or collectives could make large clusters of these functions, where many functions call other functions, and continuous data is pulled in. The latter would probably require some server/database setup that ingests Squiggle files.
I think the comprehensive end is significantly more exciting than simpler use cases but also significantly more challenging. Its equivalent to going from Docker the core technology, to Docker hub, then making an attempt at Kubernetes. Here we barely have a prototype of the proverbial Docker, so theres a lot of work to do. I think the comprehensive end is significantly more exciting than simpler use cases but also significantly more challenging. Its equivalent to going from Docker the core technology, to Docker hub, then making an attempt at Kubernetes. Here we barely have a prototype of the proverbial Docker, so theres a lot of work to do.
### Why doesnt this exist already? ### Why doesnt this exist already?
I will briefly pause here to flag that I believe the comprehensive end seems fairly obvious as a goal and Im quite surprised it hasnt really been attempted yet, from what I can tell. I imagine such work could be useful to many important actors, conditional on them understanding how to use it. I will briefly pause here to flag that I believe the comprehensive end seems fairly obvious as a goal and Im quite surprised it hasnt really been attempted yet, from what I can tell. I imagine such work could be useful to many important actors, conditional on them understanding how to use it.
My best guess is this is due to some mix between: My best guess is this is due to some mix between:
* Its too technical for many people to be comfortable with.
* Theres a fair amount of work to be done, and its difficult to monetize quickly. - Its too technical for many people to be comfortable with.
* Theres been an odd, long-standing cultural bias against clearly intuitive estimates. - Theres a fair amount of work to be done, and its difficult to monetize quickly.
* The work is substantially harder than I realize. - Theres been an odd, long-standing cultural bias against clearly intuitive estimates.
- The work is substantially harder than I realize.
# Related Tools # Related Tools
**Guesstimate** **Guesstimate**
I previously made Guesstimate and take a lot of inspiration from it. Squiggle will be a language that uses pure text, not a spreadsheet. Perhaps Squiggle could one day be made available within Guesstimate cells. I previously made Guesstimate and take a lot of inspiration from it. Squiggle will be a language that uses pure text, not a spreadsheet. Perhaps Squiggle could one day be made available within Guesstimate cells.
@ -181,11 +195,12 @@ Knowledge graphs seem like the best tool for describing semantic relationships i
For example, someone could write a function that takes in a “standard location schema” and returns a calculation of the number of piano tuners at that location. Later when someone queries Wikipedia for a town, it will recognize that that town has data on [Wikidata](https://www.wikidata.org/wiki/Wikidata:Main_Page) , which can be easily converted into the necessary schema. For example, someone could write a function that takes in a “standard location schema” and returns a calculation of the number of piano tuners at that location. Later when someone queries Wikipedia for a town, it will recognize that that town has data on [Wikidata](https://www.wikidata.org/wiki/Wikidata:Main_Page) , which can be easily converted into the necessary schema.
## Next Steps ## Next Steps
Right now Im the only active developer of Squiggle. My work is split between Squiggle, writing blog posts and content, and other administrative and organizational duties for QURI. Right now Im the only active developer of Squiggle. My work is split between Squiggle, writing blog posts and content, and other administrative and organizational duties for QURI.
My first plan is to add some documentation, clean up the internals, and begin writing short programs for personal and group use. If things go well and we could find a good developer to hire, I would be excited to see what we could do after a year or two. My first plan is to add some documentation, clean up the internals, and begin writing short programs for personal and group use. If things go well and we could find a good developer to hire, I would be excited to see what we could do after a year or two.
Ambitious versions of Squiggle would be a *lot* of work (as in, 50 to 5000+ engineer years work), so I want to take things one step at a time. I would hope that if progress is sufficiently exciting, it would be possible to either raise sufficient funding or encourage other startups and companies to attempt their own similar solutions. Ambitious versions of Squiggle would be a _lot_ of work (as in, 50 to 5000+ engineer years work), so I want to take things one step at a time. I would hope that if progress is sufficiently exciting, it would be possible to either raise sufficient funding or encourage other startups and companies to attempt their own similar solutions.
## Footnotes ## Footnotes

View File

@ -2,7 +2,7 @@
sidebar_position: 7 sidebar_position: 7
--- ---
import { SquiggleEditor } from '../src/components/SquiggleEditor' import { SquiggleEditor } from "../src/components/SquiggleEditor";
# Squiggle Functions Reference # Squiggle Functions Reference
@ -22,7 +22,6 @@ two given numbers.
<SquiggleEditor initialSquiggleString="uniform(3, 7)" /> <SquiggleEditor initialSquiggleString="uniform(3, 7)" />
### Lognormal distribution ### Lognormal distribution
The `lognormal(mu, sigma)` returns the log of a normal distribution with parameters The `lognormal(mu, sigma)` returns the log of a normal distribution with parameters
@ -42,7 +41,6 @@ and standard deviation, using `lognormalFromMeanAndStdDev`.
<SquiggleEditor initialSquiggleString="lognormalFromMeanAndStdDev(20, 10)" /> <SquiggleEditor initialSquiggleString="lognormalFromMeanAndStdDev(20, 10)" />
### Beta distribution ### Beta distribution
The `beta(a, b)` function creates a beta distribution with parameters a and b: The `beta(a, b)` function creates a beta distribution with parameters a and b:
@ -56,7 +54,6 @@ mean.
<SquiggleEditor initialSquiggleString="exponential(1)" /> <SquiggleEditor initialSquiggleString="exponential(1)" />
### The Triangular distribution ### The Triangular distribution
The `triangular(a,b,c)` function creates a triangular distribution with lower The `triangular(a,b,c)` function creates a triangular distribution with lower
@ -84,6 +81,7 @@ As well as mixed distributions:
## Other Functions ## Other Functions
### PDF of a distribution ### PDF of a distribution
The `pdf(distribution, x)` function returns the density of a distribution at the The `pdf(distribution, x)` function returns the density of a distribution at the
given point x. given point x.
@ -104,11 +102,13 @@ or all values lower than x. It is the inverse of `inv`.
<SquiggleEditor initialSquiggleString="cdf(normal(0,1),0)" /> <SquiggleEditor initialSquiggleString="cdf(normal(0,1),0)" />
### Mean of a distribution ### Mean of a distribution
The `mean(distribution)` function gives the mean (expected value) of a distribution. The `mean(distribution)` function gives the mean (expected value) of a distribution.
<SquiggleEditor initialSquiggleString="mean(normal(5, 10))" /> <SquiggleEditor initialSquiggleString="mean(normal(5, 10))" />
### Sampling a distribution ### Sampling a distribution
The `sample(distribution)` samples a given distribution. The `sample(distribution)` samples a given distribution.
<SquiggleEditor initialSquiggleString="sample(normal(0, 10))" /> <SquiggleEditor initialSquiggleString="sample(normal(0, 10))" />

View File

@ -3,16 +3,18 @@ sidebar_position: 4
--- ---
# Future Features # Future Features
Squiggle is still very early. The main first goal is to become stable. This means having a clean codebase, having decent test coverage, and having a syntax we are reasonably confident in. Later on, there are many other features that will be interesting to explore. Squiggle is still very early. The main first goal is to become stable. This means having a clean codebase, having decent test coverage, and having a syntax we are reasonably confident in. Later on, there are many other features that will be interesting to explore.
## Programming Language Features ## Programming Language Features
- Equality (a == b) - Equality (a == b)
- If/else statements - If/else statements
- Arrays - Arrays
- Tables / Matrices - Tables / Matrices
- Simple objects - Simple objects
- A simple type system - A simple type system
- Simple module system (``Dist.Normal`` instead of ``normal``) - Simple module system (`Dist.Normal` instead of `normal`)
- A simple time library & notation - A simple time library & notation
- Optional and default paramaters for functions - Optional and default paramaters for functions
- Anonymous Functions (This is particularly convenient in cases where tiny functions are submitted in forecasting competitions) - Anonymous Functions (This is particularly convenient in cases where tiny functions are submitted in forecasting competitions)
@ -21,16 +23,17 @@ Squiggle is still very early. The main first goal is to become stable. This mean
- "Partial-domain" distributions. For example, maybe someone has a distribution for when AGI will happen, but doesn't want to make any estimates past 2200. - "Partial-domain" distributions. For example, maybe someone has a distribution for when AGI will happen, but doesn't want to make any estimates past 2200.
## Distribution Features ## Distribution Features
``Distribution.fromSamples([])``
`Distribution.fromSamples([])`
Converts a list of samples, for example, from Guesstimate, into a distribution shape. Maybe takes a list of optional parameters. Converts a list of samples, for example, from Guesstimate, into a distribution shape. Maybe takes a list of optional parameters.
``Distribution.fromCoordinates({xs, ys})`` `Distribution.fromCoordinates({xs, ys})`
Convert XY coordinates into a distribution. Figure out a good way to do this for continuous, discrete, and mixed distributions. Convert XY coordinates into a distribution. Figure out a good way to do this for continuous, discrete, and mixed distributions.
[Metalog Distribution](https://en.wikipedia.org/wiki/Metalog_distribution) [Metalog Distribution](https://en.wikipedia.org/wiki/Metalog_distribution)
Add the Metalog distribution, and some convenient methods for generating these distributions. This might be a bit tricky because we might need or build a library to fit data. There's no Metalog javascript library yet, this would be pretty useful. There's already a Metalog library in Python, so that one could be used for inspiration. Add the Metalog distribution, and some convenient methods for generating these distributions. This might be a bit tricky because we might need or build a library to fit data. There's no Metalog javascript library yet, this would be pretty useful. There's already a Metalog library in Python, so that one could be used for inspiration.
``Distribution.smoothen(p)`` `Distribution.smoothen(p)`
Takes a distribution and smoothens it. For example, [Elicit Forecast](https://forecast.elicit.org/) does something like this, with uniform distributions. Takes a distribution and smoothens it. For example, [Elicit Forecast](https://forecast.elicit.org/) does something like this, with uniform distributions.
## Major Future Additions ## Major Future Additions
@ -72,39 +75,39 @@ It might be useful to allow people to annotate functions and variables with long
Right now, Monte Carlo simulations are totally random. It would be nicer to be able to enter a seed somehow in order to control the randomness. Or, with the same seed, the function should always return the same values. This would make debugging and similar easier. Right now, Monte Carlo simulations are totally random. It would be nicer to be able to enter a seed somehow in order to control the randomness. Or, with the same seed, the function should always return the same values. This would make debugging and similar easier.
## Major Standard Language Features ## Major Standard Language Features
- Some testing story. - Some testing story.
- A custom code highlighting format. - A custom code highlighting format.
- Possibly a decent web GUI (a much more advanced playground). - Possibly a decent web GUI (a much more advanced playground).
- A VS Code extention and similar. - A VS Code extention and similar.
## Bugs ## Bugs
- Discrete distributions are particularly buggy. Try ``mm(1,2,3,4,5,6,7,8,9,10) .* (5 to 8)``
- Discrete distributions are particularly buggy. Try `mm(1,2,3,4,5,6,7,8,9,10) .* (5 to 8)`
## New Functions ## New Functions
### Distributions ### Distributions
```js ```js
cauchy() cauchy();
pareto() pareto();
metalog() metalog();
``` ```
Possibly change mm to mix, or mx(). Also, change input format, maybe to mx([a,b,c], [a,b,c]). Possibly change mm to mix, or mx(). Also, change input format, maybe to mx([a,b,c], [a,b,c]).
### Functions ### Functions
```js ```js
samples(distribution, n) samples(distribution, n);
toPdf(distribution) toPdf(distribution);
toCdf(distribution) toCdf(distribution);
toHash(distribution) toHash(distribution);
trunctate(distribution, leftValue, rightValue) trunctate(distribution, leftValue, rightValue);
leftTrunctate(distribution, leftValue) leftTrunctate(distribution, leftValue);
rightTrunctate(distribution, rightValue) rightTrunctate(distribution, rightValue);
distributionFromSamples(array, params) distributionFromSamples(array, params);
distributionFromPoints() distributionFromPoints();
distributionFromHash() distributionFromHash();
``` ```

View File

@ -5,8 +5,9 @@ sidebar_position: 3
# Javascript Libraries # Javascript Libraries
There are two JavaScript packages currently available for Squiggle: There are two JavaScript packages currently available for Squiggle:
- [`@quri/squiggle-lang`](https://www.npmjs.com/package/@quri/squiggle-lang)
- [`@quri/squiggle-components`](https://www.npmjs.com/package/@quri/squiggle-components) - [`@quri/squiggle-lang`](https://www.npmjs.com/package/@quri/squiggle-lang)
- [`@quri/squiggle-components`](https://www.npmjs.com/package/@quri/squiggle-components)
Types are available for both packages. Types are available for both packages.

View File

@ -2,7 +2,7 @@
sidebar_position: 2 sidebar_position: 2
--- ---
import { SquiggleEditor } from '../src/components/SquiggleEditor' import { SquiggleEditor } from "../src/components/SquiggleEditor";
# Squiggle Language # Squiggle Language
@ -13,8 +13,10 @@ it is by simply looking at examples.
As an example: As an example:
<SquiggleEditor initialSquiggleString={`value_of_work = 10 to 70 <SquiggleEditor
value_of_work`} /> initialSquiggleString={`value_of_work = 10 to 70
value_of_work`}
/>
Squiggle can declare variables (`value_of_work = 10 to 70`) and declare exports Squiggle can declare variables (`value_of_work = 10 to 70`) and declare exports
(the lone `value_of_work` line). Variables can be used later in a squiggle program (the lone `value_of_work` line). Variables can be used later in a squiggle program
@ -30,7 +32,8 @@ the exports can be expressions, such as:
Squiggle supports functions, including the rendering of functions: Squiggle supports functions, including the rendering of functions:
<SquiggleEditor initialSquiggleString={`ozzie_estimate(t) = lognormal({mean: 3 + (t+.1)^2.5, stdev: 8}) <SquiggleEditor
initialSquiggleString={`ozzie_estimate(t) = lognormal({mean: 3 + (t+.1)^2.5, stdev: 8})
ozzie_estimate ozzie_estimate
`} /> `}
/>

View File

@ -2,6 +2,6 @@
sidebar_position: 2 sidebar_position: 2
--- ---
import { SquigglePlayground } from '../src/components/SquigglePlayground' import { SquigglePlayground } from "../src/components/SquigglePlayground";
<SquigglePlayground initialSquiggleString="normal(0,1)"/> <SquigglePlayground initialSquiggleString="normal(0,1)" />

View File

@ -4,16 +4,16 @@ sidebar_position: 5
# Three Formats of Distributions # Three Formats of Distributions
*Author: Ozzie Gooen* _Author: Ozzie Gooen_
*Written on: Feb 19, 2022* _Written on: Feb 19, 2022_
Probability distributions have several subtle possible formats. Three important ones that we deal with in Squiggle are symbolic, sample set, and graph formats. Probability distributions have several subtle possible formats. Three important ones that we deal with in Squiggle are symbolic, sample set, and graph formats.
_Symbolic_ formats are just the math equations. ``normal(5,3)`` is the symbolic representation of a normal distribution. _Symbolic_ formats are just the math equations. `normal(5,3)` is the symbolic representation of a normal distribution.
When you sample distributions (usually starting with symbolic formats), you get lists of samples. Monte Carlo techniques return lists of samples. Lets call this the “_Sample Set_” format. When you sample distributions (usually starting with symbolic formats), you get lists of samples. Monte Carlo techniques return lists of samples. Lets call this the “_Sample Set_” format.
Lastly is what Ill refer to as the _Graph_ format. It describes the coordinates, or the shape, of the distribution. You can save these formats in JSON, for instance, like, ``{xs: [1, 2, 3, 4…], ys: [.0001, .0003, .002, …]}``. Lastly is what Ill refer to as the _Graph_ format. It describes the coordinates, or the shape, of the distribution. You can save these formats in JSON, for instance, like, `{xs: [1, 2, 3, 4…], ys: [.0001, .0003, .002, …]}`.
Symbolic, Sample Set, and Graph formats all have very different advantages and disadvantages. Symbolic, Sample Set, and Graph formats all have very different advantages and disadvantages.
@ -25,8 +25,8 @@ Note that the name "Symbolic" is fairly standard, but I haven't found common nam
Mathematical representations. Require analytic solutions. These are often ideal where they can be applied, but apply to very few actual functions. Typically used sparsely, except for the starting distributions (before any computation is performed). Mathematical representations. Require analytic solutions. These are often ideal where they can be applied, but apply to very few actual functions. Typically used sparsely, except for the starting distributions (before any computation is performed).
**Examples** **Examples**
```Normal(5,2)``` `Normal(5,2)`
```pdf(normal(2,5), 1.2) + beta(5, log(2))``` `pdf(normal(2,5), 1.2) + beta(5, log(2))`
**How to Do Computation** **How to Do Computation**
To perform calculations of symbolic systems, you need to find analytical solutions. For example, there are equations to find the pdf or cdf of most distribution shapes at any point. There are also lots of simplifications that could be done in particular situations. For example, theres an analytical solution for combining normal distributions. To perform calculations of symbolic systems, you need to find analytical solutions. For example, there are equations to find the pdf or cdf of most distribution shapes at any point. There are also lots of simplifications that could be done in particular situations. For example, theres an analytical solution for combining normal distributions.
@ -35,25 +35,29 @@ To perform calculations of symbolic systems, you need to find analytical solutio
The Metalog distribution seems like it can represent almost any reasonable distribution. Its symbolic. This is great for storage, but its not clear if it helps with calculation. My impression is that we dont have symbolic ways of doing most functions (addition, multiplication, etc) on metalog distributions. Also, note that it can take a fair bit of computation to fit a shape to the Metalog distribution. The Metalog distribution seems like it can represent almost any reasonable distribution. Its symbolic. This is great for storage, but its not clear if it helps with calculation. My impression is that we dont have symbolic ways of doing most functions (addition, multiplication, etc) on metalog distributions. Also, note that it can take a fair bit of computation to fit a shape to the Metalog distribution.
**Advantages** **Advantages**
* Maximally compressed; i.e. very easy to store.
* Very readable. - Maximally compressed; i.e. very easy to store.
* When symbolic operations are feasible and easy to discover, they are trivially fast and completely accurate. - Very readable.
- When symbolic operations are feasible and easy to discover, they are trivially fast and completely accurate.
**Disadvantages** **Disadvantages**
* Its often either impossible or computationally infeasible to find analytical solutions to most symbolic equations.
* Solving symbolic equations requires very specialized tooling thats very rare. There are a few small symbolic solver libraries out there, but not many. Wolfram Research is the main group that seems very strong here, and their work is mostly closed source + expensive. - Its often either impossible or computationally infeasible to find analytical solutions to most symbolic equations.
- Solving symbolic equations requires very specialized tooling thats very rare. There are a few small symbolic solver libraries out there, but not many. Wolfram Research is the main group that seems very strong here, and their work is mostly closed source + expensive.
**Converting to Graph Formats** **Converting to Graph Formats**
* Very easy. Choose X points such that you capture most of the distribution (you can set a threshold, like 99.9%). For each X point, calculate the pdf, and save as the Y points.
- Very easy. Choose X points such that you capture most of the distribution (you can set a threshold, like 99.9%). For each X point, calculate the pdf, and save as the Y points.
**Converting to Sample List Formats** **Converting to Sample List Formats**
* Very easy. Just sample a bunch of times. The regular way is to randomly sample (This is trivial to do for all distributions with inverse-cdf functions.) If you want to get more fancy, you could provide extra samples from the tails, that would be weighted lower. Or, you could take samples in equal distances (of probability mass) along the entire distribution, then optionally shuffle it. (In the latter case, these would not be random samples, but sometimes thats fine.)
- Very easy. Just sample a bunch of times. The regular way is to randomly sample (This is trivial to do for all distributions with inverse-cdf functions.) If you want to get more fancy, you could provide extra samples from the tails, that would be weighted lower. Or, you could take samples in equal distances (of probability mass) along the entire distribution, then optionally shuffle it. (In the latter case, these would not be random samples, but sometimes thats fine.)
**How to Visualize** **How to Visualize**
Convert to graph, then display that. (Optionally, you can also convert to samples, then display those using a histogram, but this is often worse you have both options.) Convert to graph, then display that. (Optionally, you can also convert to samples, then display those using a histogram, but this is often worse you have both options.)
## Graph Formats ## Graph Formats
**TLDR** **TLDR**
Lists of the x-y coordinates of the shape of a distribution. (Usually the pdf, which is more compressed than the cdf). Some key functions (like pdf, cdf) and manipulations can work on almost any graphally-described distribution. Lists of the x-y coordinates of the shape of a distribution. (Usually the pdf, which is more compressed than the cdf). Some key functions (like pdf, cdf) and manipulations can work on almost any graphally-described distribution.
@ -65,37 +69,44 @@ See [this facebook thread](https://www.facebook.com/ozzie.gooen/posts/1016593626
Use graph techniques. These can be fairly computationally-intensive (particularly finding integrals, which take a whole lot of adding). In the case that you want to multiply independent distributions, you can try convolution, but its pretty expensive. Use graph techniques. These can be fairly computationally-intensive (particularly finding integrals, which take a whole lot of adding). In the case that you want to multiply independent distributions, you can try convolution, but its pretty expensive.
**Examples** **Examples**
``{xs: [1, 2, 3, 4…], ys: [.0001, .0003, .002, .04, ...]} `` `{xs: [1, 2, 3, 4…], ys: [.0001, .0003, .002, .04, ...]} `
``[[1, .0001], [2, .0003], [3, .002]...] `` `[[1, .0001], [2, .0003], [3, .002]...] `
**Advantages** **Advantages**
* Much more compressed than Sample List formats, but much less compressed than Symbolic formats.
* Many functions (pdf, cdf, percentiles, mean, integration, etc) and manipulations (truncation, scaling horizontally or vertically), are possible on essentially all graph distributions. - Much more compressed than Sample List formats, but much less compressed than Symbolic formats.
- Many functions (pdf, cdf, percentiles, mean, integration, etc) and manipulations (truncation, scaling horizontally or vertically), are possible on essentially all graph distributions.
**Disadvantages** **Disadvantages**
* Most calculations are infeasible/impossible to perform graphally. In these cases, you need to use sampling.
* Not as accurate or fast as symbolic methods, where the symbolic methods are applicable. - Most calculations are infeasible/impossible to perform graphally. In these cases, you need to use sampling.
* The tails get cut off, which is subideal. Its assumed that the value of the pdf outside of the bounded range is exactly 0, which is not correct. (Note: If you have ideas on how to store graph formats that dont cut off tails, let me know) - Not as accurate or fast as symbolic methods, where the symbolic methods are applicable.
- The tails get cut off, which is subideal. Its assumed that the value of the pdf outside of the bounded range is exactly 0, which is not correct. (Note: If you have ideas on how to store graph formats that dont cut off tails, let me know)
**Converting to Symbolic Formats** **Converting to Symbolic Formats**
* Okay, if you are okay with a Metalog approximation or similar. Metaculus uses an additive combination of up to [Logistic distributions](https://www.metaculus.com/help/faq/); you could also fit this. Fitting takes a little time (it requires several attempts and some optimization), can be arbitrarily accurate.
* If you want to be very fancy, you could try to fit graph distributions into normal / lognormal / etc. but this seems like a lot of work for little gain. - Okay, if you are okay with a Metalog approximation or similar. Metaculus uses an additive combination of up to [Logistic distributions](https://www.metaculus.com/help/faq/); you could also fit this. Fitting takes a little time (it requires several attempts and some optimization), can be arbitrarily accurate.
- If you want to be very fancy, you could try to fit graph distributions into normal / lognormal / etc. but this seems like a lot of work for little gain.
**Converting to Sample List Formats** **Converting to Sample List Formats**
* Just sample a lot. The same as converting symbolic formats into samples.
- Just sample a lot. The same as converting symbolic formats into samples.
**How to Visualize** **How to Visualize**
* Its already in a good format for visualization, just plot it in any library.
- Its already in a good format for visualization, just plot it in any library.
**Handling Long Tails / Optimization** **Handling Long Tails / Optimization**
* You can choose specific points to use to save computation. For example, taking extra points at the ends.
- You can choose specific points to use to save computation. For example, taking extra points at the ends.
**Additional Metadata** **Additional Metadata**
* The format mentioned above does not suggest any specific form of interpolation, or strategy of dealing with the tails. Several interpolation methods are possible; for example, linear interpolation, or stepwise interpolation.
- The format mentioned above does not suggest any specific form of interpolation, or strategy of dealing with the tails. Several interpolation methods are possible; for example, linear interpolation, or stepwise interpolation.
**Potential Alternatives** **Potential Alternatives**
* [Bézier curves](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) could, in theory, be more optimal. Bézier are used for vector image programs. They represent a more complicated format than a list of x-y coordinate pairs, but come with much more flexibility. Arguably, they sit somewhere between fitting distributions to Metalog distributions, and just taking many x-y points.
- [Bézier curves](https://en.wikipedia.org/wiki/B%C3%A9zier_curve) could, in theory, be more optimal. Bézier are used for vector image programs. They represent a more complicated format than a list of x-y coordinate pairs, but come with much more flexibility. Arguably, they sit somewhere between fitting distributions to Metalog distributions, and just taking many x-y points.
## Sample Set Formats ## Sample Set Formats
@ -106,19 +117,21 @@ Random samples. Use Monte Carlo simulation to perform calculations. This is the
Use [Monte Carlo methods](https://en.wikipedia.org/wiki/Monte_Carlo_method). You could get fancy with these with a [probabilistic programming language](https://en.wikipedia.org/wiki/Probabilistic_programming), which often have highly optimized Monte Carlo tooling. Variational inference is used for very similar problems. Use [Monte Carlo methods](https://en.wikipedia.org/wiki/Monte_Carlo_method). You could get fancy with these with a [probabilistic programming language](https://en.wikipedia.org/wiki/Probabilistic_programming), which often have highly optimized Monte Carlo tooling. Variational inference is used for very similar problems.
**Examples** **Examples**
``[3.23848, 4.82081, 1.382833, 9.238383…]`` `[3.23848, 4.82081, 1.382833, 9.238383…]`
**Advantages** **Advantages**
* Monte Carlo methods are effectively the only ways to calculate many/most functions.
* The use of Monte Carlo methods make for very easy sensitivity analysis. - Monte Carlo methods are effectively the only ways to calculate many/most functions.
* [Probabilistic inference](https://machinelearningmastery.com/markov-chain-monte-carlo-for-probability/) is only possible using Monte Carlo methods. - The use of Monte Carlo methods make for very easy sensitivity analysis.
* In some cases, Monte Carlo computation functionally represents possible worlds. Theres no very clear line between Monte Carlo methods and agent based modeling simulations. - [Probabilistic inference](https://machinelearningmastery.com/markov-chain-monte-carlo-for-probability/) is only possible using Monte Carlo methods.
* You can handle math with distributions that are correlated with each other. (I believe, but am not sure). - In some cases, Monte Carlo computation functionally represents possible worlds. Theres no very clear line between Monte Carlo methods and agent based modeling simulations.
- You can handle math with distributions that are correlated with each other. (I believe, but am not sure).
**Disadvantages** **Disadvantages**
* Monte Carlo methods can be very slow.
* Requires fairly heavy tooling to make efficient. - Monte Carlo methods can be very slow.
* Sampling methods are very lossy, especially for tails. - Requires fairly heavy tooling to make efficient.
- Sampling methods are very lossy, especially for tails.
**Converting to Symbolic Formats** **Converting to Symbolic Formats**
I dont know of a straightforward way of doing this. Convert to Sample List first, then you can convert to Metalog or similar. I dont know of a straightforward way of doing this. Convert to Sample List first, then you can convert to Metalog or similar.
@ -127,17 +140,16 @@ I dont know of a straightforward way of doing this. Convert to Sample List fi
[Kernel density estimation](https://en.wikipedia.org/wiki/Kernel_density_estimation) works. However, it requires a few parameters from the user, for tuning. There are functions to estimate these parameters, but this is tricky. Two forms of density estimation are shown as code [here](https://github.com/jasondavies/science.js/blob/master/src/stats/bandwidth.js). Theres some more description in the webppl documentation [here](https://webppl.readthedocs.io/en/master/distributions.html#KDE). [Kernel density estimation](https://en.wikipedia.org/wiki/Kernel_density_estimation) works. However, it requires a few parameters from the user, for tuning. There are functions to estimate these parameters, but this is tricky. Two forms of density estimation are shown as code [here](https://github.com/jasondavies/science.js/blob/master/src/stats/bandwidth.js). Theres some more description in the webppl documentation [here](https://webppl.readthedocs.io/en/master/distributions.html#KDE).
**Handling Long Tails / Optimization** **Handling Long Tails / Optimization**
* You can weight samples differently. This allows you to save more at the tails, for more granularity there, without biasing the results. (Im not sure how difficult this would be.)
- You can weight samples differently. This allows you to save more at the tails, for more granularity there, without biasing the results. (Im not sure how difficult this would be.)
**How to Visualize** **How to Visualize**
Use a histogram. Use a histogram.
| | Symbolic | Symbolic(metalog) | Numeric | Samples/MC | | | Symbolic | Symbolic(metalog) | Numeric | Samples/MC |
|------------------------|--------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------|------------------------------------------------------------------------------------------------|-------------------------------------| | ---------------------- | ------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| Example | normal(5,2) | metalog([(2,3)]) | [[1,2,3,4], [3,5,9,10]] | [1.38483, 0.233, 38.8383, …] | | Example | normal(5,2) | metalog([(2,3)]) | [[1,2,3,4], [3,5,9,10]] | [1.38483, 0.233, 38.8383, …] |
| Techniques | Analytic | Analytic | Numeric | Monte Carlo, variational inference | | Techniques | Analytic | Analytic | Numeric | Monte Carlo, variational inference |
| Available calculations | Pdf(), cdf(), sample, inverse Add or multiply normal distributions Add lognormal distributions Select other calculations | Pdf(), cdf(), sample(), inverseCdf() | Pointwise operations Truncate Mixture Select regular operations by constants (normal(5,2) * 3) | Normal operations, most functions. Not pointwise functions. | | Available calculations | Pdf(), cdf(), sample, inverse Add or multiply normal distributions Add lognormal distributions Select other calculations | Pdf(), cdf(), sample(), inverseCdf() | Pointwise operations Truncate Mixture Select regular operations by constants (normal(5,2) \* 3) | Normal operations, most functions. Not pointwise functions. |
| Use for computation | Lossless, Very fast, Extremely limited | | Medium speed, Minor accuracy loss, Select useful, but limited functions | Slow and lossy, but very general-purpose. | | Use for computation | Lossless, Very fast, Extremely limited | | Medium speed, Minor accuracy loss, Select useful, but limited functions | Slow and lossy, but very general-purpose. |
| Use for storage | Tiny, Lossless, Extremely limited | (Assuming other data is fit to metalog) High information densityt | Medium information density | Low information density | | Use for storage | Tiny, Lossless, Extremely limited | (Assuming other data is fit to metalog) High information densityt | Medium information density | Low information density |

View File

@ -1,56 +1,62 @@
// @ts-check // @ts-check
// Note: type annotations allow type checking and IDEs autocompletion // Note: type annotations allow type checking and IDEs autocompletion
const lightCodeTheme = require('prism-react-renderer/themes/github'); const lightCodeTheme = require("prism-react-renderer/themes/github");
const darkCodeTheme = require('prism-react-renderer/themes/dracula'); const darkCodeTheme = require("prism-react-renderer/themes/dracula");
const path = require('path'); const path = require("path");
/** @type {import('@docusaurus/types').Config} */ /** @type {import('@docusaurus/types').Config} */
const config = { const config = {
title: 'Squiggle (alpha)', title: "Squiggle (alpha)",
tagline: "Estimation language for forecasters", tagline: "Estimation language for forecasters",
url: 'https://squiggle-language.com', url: "https://squiggle-language.com",
baseUrl: '/', baseUrl: "/",
onBrokenLinks: 'throw', onBrokenLinks: "throw",
onBrokenMarkdownLinks: 'warn', onBrokenMarkdownLinks: "warn",
favicon: 'img/favicon.ico', favicon: "img/favicon.ico",
organizationName: 'QURIResearch', // Usually your GitHub org/user name. organizationName: "QURIResearch", // Usually your GitHub org/user name.
projectName: 'squiggle', // Usually your repo name. projectName: "squiggle", // Usually your repo name.
plugins: [ plugins: [
() => ({ () => ({
configureWebpack(config, isServer, utils, content) { configureWebpack(config, isServer, utils, content) {
return { return {
resolve: { resolve: {
alias : { alias: {
"@quri/squiggle-components": path.resolve(__dirname, "../components/src"), "@quri/squiggle-components": path.resolve(
"@quri/squiggle-lang": path.resolve(__dirname, "../squiggle-lang/src/js") __dirname,
} "../components/src"
} ),
"@quri/squiggle-lang": path.resolve(
__dirname,
"../squiggle-lang/src/js"
),
},
},
}; };
} },
}) }),
], ],
presets: [ presets: [
[ [
'classic', "classic",
/** @type {import('@docusaurus/preset-classic').Options} */ /** @type {import('@docusaurus/preset-classic').Options} */
({ ({
docs: { docs: {
sidebarPath: require.resolve('./sidebars.js'), sidebarPath: require.resolve("./sidebars.js"),
// Please change this to your repo. // Please change this to your repo.
editUrl: 'https://github.com/foretold-app/squiggle/tree/main/packages/website/', editUrl:
"https://github.com/foretold-app/squiggle/tree/main/packages/website/",
}, },
blog: { blog: {
showReadingTime: true, showReadingTime: true,
// Please change this to your repo. // Please change this to your repo.
editUrl: editUrl:
'https://github.com/foretold-app/squiggle/tree/main/packages/website/', "https://github.com/foretold-app/squiggle/tree/main/packages/website/",
}, },
theme: { theme: {
customCss: require.resolve('./src/css/custom.css'), customCss: require.resolve("./src/css/custom.css"),
}, },
}), }),
], ],
@ -60,54 +66,54 @@ const config = {
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */ /** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({ ({
navbar: { navbar: {
title: 'Squiggle', title: "Squiggle",
logo: { logo: {
alt: 'Squiggle Logo', alt: "Squiggle Logo",
src: 'img/logo.svg', src: "img/logo.svg",
}, },
items: [ items: [
{ {
type: 'doc', type: "doc",
docId: 'Introduction', docId: "Introduction",
position: 'left', position: "left",
label: 'Documentation', label: "Documentation",
}, },
{to: '/blog', label: 'Blog', position: 'left'}, { to: "/blog", label: "Blog", position: "left" },
{ {
type: 'doc', type: "doc",
docId: 'Playground', docId: "Playground",
label: 'Playground', label: "Playground",
position: 'left' position: "left",
}, },
{ {
href: 'https://github.com/QURIresearch/squiggle', href: "https://github.com/QURIresearch/squiggle",
label: 'GitHub', label: "GitHub",
position: 'right', position: "right",
}, },
], ],
}, },
footer: { footer: {
style: 'dark', style: "dark",
links: [ links: [
{ {
title: 'Blog', title: "Blog",
items: [ items: [
{ {
label: 'Overview', label: "Overview",
to: '/docs/Language', to: "/docs/Language",
}, },
], ],
}, },
{ {
title: 'More', title: "More",
items: [ items: [
{ {
label: 'Blog', label: "Blog",
to: '/blog', to: "/blog",
}, },
{ {
label: 'GitHub', label: "GitHub",
href: 'https://github.com/QURIresearch/squiggle', href: "https://github.com/QURIresearch/squiggle",
}, },
], ],
}, },

View File

@ -14,7 +14,7 @@
/** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */ /** @type {import('@docusaurus/plugin-content-docs').SidebarsConfig} */
const sidebars = { const sidebars = {
// By default, Docusaurus generates a sidebar from the docs folder structure // By default, Docusaurus generates a sidebar from the docs folder structure
tutorialSidebar: [{type: 'autogenerated', dirName: '.'}], tutorialSidebar: [{ type: "autogenerated", dirName: "." }],
// But you can create a sidebar manually // But you can create a sidebar manually
/* /*

View File

@ -1,37 +1,37 @@
import React from 'react'; import React from "react";
import clsx from 'clsx'; import clsx from "clsx";
import styles from './HomepageFeatures.module.css'; import styles from "./HomepageFeatures.module.css";
const FeatureList = [ const FeatureList = [
{ {
title: 'Probabilistic', title: "Probabilistic",
description: (
<>Squiggle makes working with probability distributions really easy.</>
),
},
{
title: "Portable",
description: ( description: (
<> <>
Squiggle makes working with probability distributions really easy. Squiggle is in a small Rescript / Javascript library. It can be used
wherever Rescript and Javascript are available.
</> </>
), ),
}, },
{ {
title: 'Portable', title: "Fast",
description: ( description: (
<> <>
Squiggle is in a small Rescript / Javascript library. It can be used wherever Rescript and Javascript are available. Squiggle tries to get as far as it can without resorting to Monte Carlo
</> simulation, but does so when necessary.
),
},
{
title: 'Fast',
description: (
<>
Squiggle tries to get as far as it can without resorting to Monte Carlo simulation, but does so when necessary.
</> </>
), ),
}, },
]; ];
function Feature({Svg, title, description}) { function Feature({ Svg, title, description }) {
return ( return (
<div className={clsx('col col--4')}> <div className={clsx("col col--4")}>
<div className="text--center padding-horiz--md"> <div className="text--center padding-horiz--md">
<h3>{title}</h3> <h3>{title}</h3>
<p>{description}</p> <p>{description}</p>

View File

@ -1,11 +1,11 @@
import BrowserOnly from '@docusaurus/BrowserOnly'; import BrowserOnly from "@docusaurus/BrowserOnly";
export function SquiggleEditor(props) { export function SquiggleEditor(props) {
return ( return (
<BrowserOnly fallback={<div>Loading...</div>}> <BrowserOnly fallback={<div>Loading...</div>}>
{() => { {() => {
const LibComponent = const LibComponent =
require('@quri/squiggle-components').SquiggleEditor; require("@quri/squiggle-components").SquiggleEditor;
return <LibComponent {...props} />; return <LibComponent {...props} />;
}} }}
</BrowserOnly> </BrowserOnly>

View File

@ -1,11 +1,11 @@
import BrowserOnly from '@docusaurus/BrowserOnly'; import BrowserOnly from "@docusaurus/BrowserOnly";
export function SquigglePlayground(props) { export function SquigglePlayground(props) {
return ( return (
<BrowserOnly fallback={<div>Loading...</div>}> <BrowserOnly fallback={<div>Loading...</div>}>
{() => { {() => {
const LibComponent = const LibComponent =
require('@quri/squiggle-components').SquigglePlayground; require("@quri/squiggle-components").SquigglePlayground;
return <LibComponent {...props} />; return <LibComponent {...props} />;
}} }}
</BrowserOnly> </BrowserOnly>

View File

@ -17,7 +17,7 @@
} }
/* For readability concerns, you should choose a lighter palette in dark mode. */ /* For readability concerns, you should choose a lighter palette in dark mode. */
html[data-theme='dark'] { html[data-theme="dark"] {
--ifm-color-primary: #25c2a0; --ifm-color-primary: #25c2a0;
--ifm-color-primary-dark: #21af90; --ifm-color-primary-dark: #21af90;
--ifm-color-primary-darker: #1fa588; --ifm-color-primary-darker: #1fa588;
@ -34,6 +34,6 @@ html[data-theme='dark'] {
padding: 0 var(--ifm-pre-padding); padding: 0 var(--ifm-pre-padding);
} }
html[data-theme='dark'] .docusaurus-highlight-code-line { html[data-theme="dark"] .docusaurus-highlight-code-line {
background-color: rgba(0, 0, 0, 0.3); background-color: rgba(0, 0, 0, 0.3);
} }

View File

@ -1,31 +1,31 @@
import React from 'react'; import React from "react";
import clsx from 'clsx'; import clsx from "clsx";
import Layout from '@theme/Layout'; import Layout from "@theme/Layout";
import Link from '@docusaurus/Link'; import Link from "@docusaurus/Link";
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import styles from './index.module.css'; import styles from "./index.module.css";
import HomepageFeatures from '../components/HomepageFeatures'; import HomepageFeatures from "../components/HomepageFeatures";
function HomepageHeader() { function HomepageHeader() {
const {siteConfig} = useDocusaurusContext(); const { siteConfig } = useDocusaurusContext();
return ( return (
<header className={clsx('hero hero--primary', styles.heroBanner)}> <header className={clsx("hero hero--primary", styles.heroBanner)}>
<div className="container"> <div className="container">
<h1 className="hero__title">{siteConfig.title}</h1> <h1 className="hero__title">{siteConfig.title}</h1>
<p className="hero__subtitle">{siteConfig.tagline}</p> <p className="hero__subtitle">{siteConfig.tagline}</p>
<div className={styles.buttons}> <div className={styles.buttons}></div>
</div>
</div> </div>
</header> </header>
); );
} }
export default function Home() { export default function Home() {
const {siteConfig} = useDocusaurusContext(); const { siteConfig } = useDocusaurusContext();
return ( return (
<Layout <Layout
title={`Hello from ${siteConfig.title}`} title={`Hello from ${siteConfig.title}`}
description="Description will go into a meta tag in <head />"> description="Description will go into a meta tag in <head />"
>
<HomepageHeader /> <HomepageHeader />
<main> <main>
<HomepageFeatures /> <HomepageFeatures />