Squiggle Language Documentation

website·Indexed 33 days ago

https://squiggle-language.com

Documentation for the Squiggle language, featuring a comprehensive API for handling probability distributions (Dist, SampleSet, PointSet, Sym), mathematical operations, and data visualization via the Plot and Scale modules. Includes guides on language features, distribution functions, and ecosystem tooling for Node.js, VS Code, and LLM integration, including a dedicated style guide and prompt templates for GPT and Claude.

Tokens
27.9K
Snippets
178
Records
297
Agent score
68%

What's inside Squiggle

  1. Overview of the Squiggle programming language

    Squiggle is a minimalist, free, and open-source programming language designed for probabilistic estimation and intuitively-driven quantitative estimation. It allows users to perform math with probability distributions and encode functions as forecasts. Unlike full probabilistic programming languages, Squiggle does not support Bayesian inference or substantial data analysis; it is specifically optimized for estimation and rapid prototyping of small to medium models.
  2. Overview of the Squiggle Date type

    Dates in Squiggle are an immutable date-time type stored as milliseconds since the epoch. Because they are immutable, any function that modifies a date returns a new Date instance. Dates are typically used in conjunction with Duration values.
  3. Overview of Squiggle Probabilistic Programming

    Squiggle is a language designed to simplify working with probability distributions. It optimizes performance by avoiding Monte Carlo simulations whenever possible, resorting to them only when necessary for the specific computation.
  4. Overview of PointSet distributions

    Point set distributions are one of three distribution formats in Squiggle. They represent both discrete and continuous distributions as a list of x-y coordinates. Note that the point set format allows for the representation of invalid probability distributions, such as shapes with negative values or non-normalized shapes.
  5. Overview of Squiggle Multi-Module Project Architecture

    Squiggle uses a 'Functional Core, Imperative Shell' architecture where the project state is immutable and updated by dispatching actions. The system is content-addressable; modules and outputs are identified by SHA-256 hashes based on their code, name, and import pins.

    Key concepts include:

    • Project (SqProject): The main class providing public APIs to run multi-module projects.
    • Project State (ProjectState): The immutable current state containing all modules and computed outputs.
    • Module (SqModule): A single Squiggle file with metadata (name and import pins).
    • Module Output (SqModuleOutput): The computed values of a module within a specific environment.
    • Head: A named entrypoint to the module graph. Modules not reachable from any head are eventually garbage collected.
    • Pin: A hash for an import that ensures immutability and reproducibility.
  6. Overview of Squiggle Distribution types

    Distributions are the primary data type in Squiggle. They exist in three formats: point set, sample set, and symbolic. By default, distributions are created as sample sets. To create a symbolic distribution, use the Sym. namespace (e.g., Sym.normal). Certain operations, such as scoring and pointwise math, require the point set format; Squiggle will automatically perform a lossy conversion to point set if needed.
  7. Overview of SampleSet distributions

    SampleSet distributions are one of three distribution formats in Squiggle. Internally, they are stored as a list of numbers. They are primarily used for Monte Carlo calculations. While all regular distribution functions work on SampleSet distributions, there are specific SampleSet-only functions for manipulation and conversion.
  8. Overview of Squiggle Lists

    Lists in Squiggle are immutable data structures that can hold any type of value, similar to JavaScript arrays or Python lists. Because they are immutable, any function that modifies a list will return a new list rather than altering the original.
    myList = [1, 2, 3, normal(5,2), "hello"]
  9. Overview of Squiggle Tag metadata

    The Tag module provides metadata that can be attached to Squiggle variables. While tags can be accessed at runtime, they are primarily used to configure how variables appear in the Squiggle Playground and other visualizations. Tags can be applied using Tag.get[Name] functions or via decorators.
  10. Overview of Squiggle AI

    Squiggle AI is a natural language tool hosted on SquiggleHub that allows users to write and improve Squiggle code. Users must be logged into SquiggleHub to access the tool. It currently utilizes Claude Sonnet 3.5 and employs prompt caching (approximately 20k tokens) to maintain context about the Squiggle language.
  11. Overview of the Duration type

    The Duration type represents a length of time. While internally stored as milliseconds, durations are typically expressed and manipulated using units such as minutes, hours, days, and years. They are commonly used in conjunction with Date values.