diff --git a/examples/decay.squiggle b/examples/decay.squiggle new file mode 100644 index 00000000..60f4c95e --- /dev/null +++ b/examples/decay.squiggle @@ -0,0 +1,20 @@ +# The following code was provided by Nuño Sempere, it comes directly from the post https://www.lesswrong.com/s/rDe8QE5NvXcZYzgZ3/p/j8o6sgRerE3tqNWdj +## Initial setup +yearly_probability_max = 0.95 +yearly_probability_min = 0.66 +period_probability_function(epsilon, yearly_probability) = 1 - (1 - yearly_probability) ^ (1 / epsilon) +probability_decayed(t, time_periods, period_probability) = 1 - (1 - period_probability) ^ (time_periods - t) + +## Monthly decomposition +months_in_a_year=12 + +monthly_probability_min = period_probability_function(months_in_a_year, yearly_probability_min) +monthly_probability_max = period_probability_function(months_in_a_year, yearly_probability_max) + +probability_decayed_monthly_min(t) = probability_decayed(t, months_in_a_year, monthly_probability_min) +probability_decayed_monthly_max(t) = probability_decayed(t, months_in_a_year, monthly_probability_max) +probability_decayed_monthly(t) = probability_decayed_monthly_min(t) to probability_decayed_monthly_max(t) + +probability_decayed_monthly +## probability_decayed_monthly(6) +## mean(probability_decayed_monthly(6)) diff --git a/examples/givedirectly.squiggle b/examples/givedirectly.squiggle new file mode 100644 index 00000000..16dda3a7 --- /dev/null +++ b/examples/givedirectly.squiggle @@ -0,0 +1,38 @@ +# This is a cost effectiveness analysis of givedirectly, originally done by givewell, and translated into Squiggle by Sam Nolan +donation_size = 10000 +proportion_of_funding_available = beta(10, 2) +total_funding_available = donation_size * proportion_of_funding_available +household_size = 3.7 to 5.7 +size_of_transfer = 800 to 1200 +size_of_transfer_per_person = size_of_transfer / household_size + +portion_invested = 0.3 to 0.5 +amount_invested = portion_invested * size_of_transfer_per_person +amount_consumed = (1 - portion_invested) * size_of_transfer_per_person +return_on_investment = 0.08 to 0.12 +increase_in_consumption_from_investments = return_on_investment * amount_invested +baseline_consumption = 200 to 350 +log_increase_in_consumption = log(amount_consumed + baseline_consumption) + log(baseline_consumption) +log_increase_in_consumption_from_investment = log(increase_in_consumption_from_investments + baseline_consumption) + log(baseline_consumption) +investment_duration = 8 to 12 +discount_rate = beta(1.004, 20) + +present_value_excluding_last_year = log_increase_in_consumption_from_investment * (1 - (1 + discount_rate) ^ (-investment_duration)) / (log(1 + discount_rate)) + +percent_of_investment_returned = 0.15 to 0.25 + +pv_consumption_last_year = (log(baseline_consumption + amount_invested * (return_on_investment + percent_of_investment_returned)) - log(baseline_consumption)) / (1 + discount_rate)^investment_duration + +total_pv_of_cash_transfer = pv_consumption_last_year + present_value_excluding_last_year + log_increase_in_consumption + +discount_negative_spoiler = 0.03 to 0.07 + +value_discounting_spoiler = discount_negative_spoiler * total_pv_of_cash_transfer + +consumption_increase_per_household = value_discounting_spoiler * household_size + +amount_of_transfers_made = total_funding_available / size_of_transfer + +total_increase_in_ln_consumption = amount_of_transfers_made * consumption_increase_per_household + +total_increase_in_ln_consumption diff --git a/examples/wholenumberassignmentevaluation.squiggle b/examples/wholenumberassignmentevaluation.squiggle new file mode 100644 index 00000000..f441c67e --- /dev/null +++ b/examples/wholenumberassignmentevaluation.squiggle @@ -0,0 +1,3 @@ +xY1 = 99 +aBa3 = xY1 * 2 + 1 +aBa3 * xY1 + aBa3 diff --git a/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_test.res b/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_test.res deleted file mode 100644 index 1c430f3d..00000000 --- a/packages/squiggle-lang/__tests__/Distributions/SampleSetDist_test.res +++ /dev/null @@ -1,41 +0,0 @@ -open Jest -open TestHelpers - -describe("Continuous and discrete splits", () => { - makeTest( - "splits (1)", - SampleSetDist_ToPointSet.Internals.T.splitContinuousAndDiscrete([1.432, 1.33455, 2.0]), - ([1.432, 1.33455, 2.0], E.FloatFloatMap.empty()), - ) - makeTest( - "splits (2)", - SampleSetDist_ToPointSet.Internals.T.splitContinuousAndDiscrete([ - 1.432, - 1.33455, - 2.0, - 2.0, - 2.0, - 2.0, - ]) |> (((c, disc)) => (c, disc |> E.FloatFloatMap.toArray)), - ([1.432, 1.33455], [(2.0, 4.0)]), - ) - - let makeDuplicatedArray = count => { - let arr = Belt.Array.range(1, count) |> E.A.fmap(float_of_int) - let sorted = arr |> Belt.SortArray.stableSortBy(_, compare) - E.A.concatMany([sorted, sorted, sorted, sorted]) |> Belt.SortArray.stableSortBy(_, compare) - } - - let (_, discrete1) = SampleSetDist_ToPointSet.Internals.T.splitContinuousAndDiscrete( - makeDuplicatedArray(10), - ) - let toArr1 = discrete1 |> E.FloatFloatMap.toArray - makeTest("splitMedium at count=10", toArr1 |> Belt.Array.length, 10) - - let (_c, discrete2) = SampleSetDist_ToPointSet.Internals.T.splitContinuousAndDiscrete( - makeDuplicatedArray(500), - ) - let toArr2 = discrete2 |> E.FloatFloatMap.toArray - makeTest("splitMedium at count=500", toArr2 |> Belt.Array.length, 500) - // makeTest("foo", [] |> Belt.Array.length, 500) -}) diff --git a/packages/squiggle-lang/__tests__/E/splitContinuousAndDiscrete_test.res b/packages/squiggle-lang/__tests__/E/splitContinuousAndDiscrete_test.res new file mode 100644 index 00000000..a52227ee --- /dev/null +++ b/packages/squiggle-lang/__tests__/E/splitContinuousAndDiscrete_test.res @@ -0,0 +1,48 @@ +open Jest +open TestHelpers + +let prepareInputs = (ar, minWeight) => + E.A.Floats.Sorted.splitContinuousAndDiscreteForMinWeight(ar, ~minDiscreteWeight=minWeight) |> ( + ((c, disc)) => (c, disc |> E.FloatFloatMap.toArray) + ) + +describe("Continuous and discrete splits", () => { + makeTest( + "is empty, with no common elements", + prepareInputs([1.432, 1.33455, 2.0], 2), + ([1.33455, 1.432, 2.0], []), + ) + + makeTest( + "only stores 3.5 as discrete when minWeight is 3", + prepareInputs([1.432, 1.33455, 2.0, 2.0, 3.5, 3.5, 3.5], 3), + ([1.33455, 1.432, 2.0, 2.0], [(3.5, 3.0)]), + ) + + makeTest( + "doesn't store 3.5 as discrete when minWeight is 5", + prepareInputs([1.432, 1.33455, 2.0, 2.0, 3.5, 3.5, 3.5], 5), + ([1.33455, 1.432, 2.0, 2.0, 3.5, 3.5, 3.5], []), + ) + + let makeDuplicatedArray = count => { + let arr = Belt.Array.range(1, count) |> E.A.fmap(float_of_int) + let sorted = arr |> Belt.SortArray.stableSortBy(_, compare) + E.A.concatMany([sorted, sorted, sorted, sorted]) |> Belt.SortArray.stableSortBy(_, compare) + } + + let (_, discrete1) = E.A.Floats.Sorted.splitContinuousAndDiscreteForMinWeight( + makeDuplicatedArray(10), + ~minDiscreteWeight=2, + ) + let toArr1 = discrete1 |> E.FloatFloatMap.toArray + makeTest("splitMedium at count=10", toArr1 |> Belt.Array.length, 10) + + let (_c, discrete2) = E.A.Floats.Sorted.splitContinuousAndDiscreteForMinWeight( + makeDuplicatedArray(500), + ~minDiscreteWeight=2, + ) + let toArr2 = discrete2 |> E.FloatFloatMap.toArray + makeTest("splitMedium at count=500", toArr2 |> Belt.Array.length, 500) + // makeTest("foo", [] |> Belt.Array.length, 500) +}) diff --git a/packages/squiggle-lang/package.json b/packages/squiggle-lang/package.json index f9157ada..0dca9ea6 100644 --- a/packages/squiggle-lang/package.json +++ b/packages/squiggle-lang/package.json @@ -45,7 +45,7 @@ "@types/jest": "^27.4.0", "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2", "bisect_ppx": "^2.7.1", - "chalk": "^4.1.2", + "chalk": "^5.0.1", "codecov": "3.8.3", "fast-check": "2.25.0", "gentype": "^4.3.0", diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res index d5dbe1cf..c19bdf7f 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.res @@ -6,6 +6,24 @@ type toSampleSetFn = t => result type scaleMultiplyFn = (t, float) => result type pointwiseAddFn = (t, t) => result +let isPointSet = (t: t) => + switch t { + | PointSet(_) => true + | _ => false + } + +let isSampleSetSet = (t: t) => + switch t { + | SampleSet(_) => true + | _ => false + } + +let isSymbolic = (t: t) => + switch t { + | Symbolic(_) => true + | _ => false + } + let sampleN = (t: t, n) => switch t { | PointSet(r) => PointSetDist.sampleNRendered(n, r) @@ -248,20 +266,24 @@ module AlgebraicCombination = { | _ => MagicNumbers.OpCost.wildcardCost } + let hasSampleSetDist = (t1: t, t2: t): bool => isSampleSetSet(t1) || isSampleSetSet(t2) + + let convolutionIsFasterThanMonteCarlo = (t1: t, t2: t): bool => + expectedConvolutionCost(t1) * expectedConvolutionCost(t2) < MagicNumbers.OpCost.monteCarloCost + + let preferConvolutionToMonteCarlo = (t1, t2, arithmeticOperation) => { + !hasSampleSetDist(t1, t2) && + Operation.Convolution.canDoAlgebraicOperation(arithmeticOperation) && + convolutionIsFasterThanMonteCarlo(t1, t2) + } + let run = (~t1: t, ~t2: t, ~arithmeticOperation): specificStrategy => { switch StrategyCallOnValidatedInputs.symbolic(arithmeticOperation, t1, t2) { | #AnalyticalSolution(_) | #Error(_) => #AsSymbolic | #NoSolution => - if Operation.Convolution.canDoAlgebraicOperation(arithmeticOperation) { - expectedConvolutionCost(t1) * expectedConvolutionCost(t2) > - MagicNumbers.OpCost.monteCarloCost - ? #AsMonteCarlo - : #AsConvolution - } else { - #AsMonteCarlo - } + preferConvolutionToMonteCarlo(t1, t2, arithmeticOperation) ? #AsConvolution : #AsMonteCarlo } } } diff --git a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi index ed2c5c03..e91803e2 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi +++ b/packages/squiggle-lang/src/rescript/Distributions/GenericDist/GenericDist.resi @@ -69,3 +69,6 @@ let mixture: ( ~scaleMultiplyFn: scaleMultiplyFn, ~pointwiseAddFn: pointwiseAddFn, ) => result + +let isSymbolic: t => bool +let isPointSet: t => bool diff --git a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist_ToPointSet.res b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist_ToPointSet.res index da9f941f..ec2bf0d0 100644 --- a/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist_ToPointSet.res +++ b/packages/squiggle-lang/src/rescript/Distributions/SampleSetDist/SampleSetDist_ToPointSet.res @@ -39,28 +39,6 @@ module Internals = { module T = { type t = array - let splitContinuousAndDiscrete = (sortedArray: t) => { - let continuous = [] - let discrete = E.FloatFloatMap.empty() - Belt.Array.forEachWithIndex(sortedArray, (index, element) => { - let maxIndex = (sortedArray |> Array.length) - 1 - let possiblySimilarElements = switch index { - | 0 => [index + 1] - | n if n == maxIndex => [index - 1] - | _ => [index - 1, index + 1] - } |> Belt.Array.map(_, r => sortedArray[r]) - let hasSimilarElement = Belt.Array.some(possiblySimilarElements, r => r == element) - hasSimilarElement - ? E.FloatFloatMap.increment(element, discrete) - : { - let _ = Js.Array.push(element, continuous) - } - - () - }) - (continuous, discrete) - } - let xWidthToUnitWidth = (samples, outputXYPoints, xWidth) => { let xyPointRange = E.A.Sorted.range(samples) |> E.O.default(0.0) let xyPointWidth = xyPointRange /. float_of_int(outputXYPoints) @@ -85,7 +63,11 @@ let toPointSetDist = ( (), ): Internals.Types.outputs => { Array.fast_sort(compare, samples) - let (continuousPart, discretePart) = E.A.Sorted.split(samples) + let minDiscreteToKeep = MagicNumbers.ToPointSet.minDiscreteToKeep(samples) + let (continuousPart, discretePart) = E.A.Floats.Sorted.splitContinuousAndDiscreteForMinWeight( + samples, + ~minDiscreteWeight=minDiscreteToKeep, + ) let length = samples |> E.A.length |> float_of_int let discrete: PointSetTypes.discreteShape = discretePart diff --git a/packages/squiggle-lang/src/rescript/MagicNumbers.res b/packages/squiggle-lang/src/rescript/MagicNumbers.res index 291f05d6..124a44f4 100644 --- a/packages/squiggle-lang/src/rescript/MagicNumbers.res +++ b/packages/squiggle-lang/src/rescript/MagicNumbers.res @@ -22,3 +22,16 @@ module OpCost = { let wildcardCost = 1000 let monteCarloCost = Environment.defaultSampleCount } + +module ToPointSet = { + /* + This function chooses the minimum amount of duplicate samples that need + to exist in order for this to be considered discrete. The tricky thing + is that there are some operations that create duplicate continuous samples, + so we can't guarantee that these only will occur because the fundamental + structure is meant to be discrete. I chose this heuristic because I think + it would strike a reasonable trade-off, but I’m really unsure what’s + best right now. + */ + let minDiscreteToKeep = samples => max(20, E.A.length(samples) / 50) +} diff --git a/packages/squiggle-lang/src/rescript/Utility/E.res b/packages/squiggle-lang/src/rescript/Utility/E.res index 88024c3b..af3d9f7f 100644 --- a/packages/squiggle-lang/src/rescript/Utility/E.res +++ b/packages/squiggle-lang/src/rescript/Utility/E.res @@ -8,7 +8,7 @@ module FloatFloatMap = { type t = Belt.MutableMap.t let fromArray = (ar: array<(float, float)>) => Belt.MutableMap.fromArray(ar, ~id=module(Id)) - let toArray = (t: t) => Belt.MutableMap.toArray(t) + let toArray = (t: t): array<(float, float)> => Belt.MutableMap.toArray(t) let empty = () => Belt.MutableMap.make(~id=module(Id)) let increment = (el, t: t) => Belt.MutableMap.update(t, el, x => @@ -20,6 +20,10 @@ module FloatFloatMap = { let get = (el, t: t) => Belt.MutableMap.get(t, el) let fmap = (fn, t: t) => Belt.MutableMap.map(t, fn) + let partition = (fn, t: t) => { + let (match, noMatch) = Belt.Array.partition(toArray(t), fn) + (fromArray(match), fromArray(noMatch)) + } } module Int = { @@ -553,18 +557,22 @@ module A = { let makeIncrementalDown = (a, b) => Array.make(a - b + 1, a) |> Array.mapi((i, c) => c - i) |> Belt.Array.map(_, float_of_int) - let split = (sortedArray: array) => { - let continuous = [] + /* + This function goes through a sorted array and divides it into two different clusters: + continuous samples and discrete samples. The discrete samples are stored in a mutable map. + Samples are thought to be discrete if they have any duplicates. + */ + let _splitContinuousAndDiscreteForDuplicates = (sortedArray: array) => { + let continuous: array = [] let discrete = FloatFloatMap.empty() - Belt.Array.forEachWithIndex(sortedArray, (_, element) => { - // let maxIndex = (sortedArray |> Array.length) - 1 - // let possiblySimilarElements = switch index { - // | 0 => [index + 1] - // | n if n == maxIndex => [index - 1] - // | _ => [index - 1, index + 1] - // } |> Belt.Array.map(_, r => sortedArray[r]) - // let hasSimilarElement = Belt.Array.some(possiblySimilarElements, r => r == element) - let hasSimilarElement = false + Belt.Array.forEachWithIndex(sortedArray, (index, element) => { + let maxIndex = (sortedArray |> Array.length) - 1 + let possiblySimilarElements = switch index { + | 0 => [index + 1] + | n if n == maxIndex => [index - 1] + | _ => [index - 1, index + 1] + } |> Belt.Array.map(_, r => sortedArray[r]) + let hasSimilarElement = Belt.Array.some(possiblySimilarElements, r => r == element) hasSimilarElement ? FloatFloatMap.increment(element, discrete) : { @@ -576,6 +584,32 @@ module A = { (continuous, discrete) } + + /* + This function works very similarly to splitContinuousAndDiscreteForDuplicates. The one major difference + is that you can specify a minDiscreteWeight. If the min discreet weight is 4, that would mean that + at least four elements needed from a specific value for that to be kept as discrete. This is important + because in some cases, we can expect that some common elements will be generated by regular operations. + The final continous array will be sorted. + */ + let splitContinuousAndDiscreteForMinWeight = ( + sortedArray: array, + ~minDiscreteWeight: int, + ) => { + let (continuous, discrete) = _splitContinuousAndDiscreteForDuplicates(sortedArray) + let keepFn = v => Belt.Float.toInt(v) >= minDiscreteWeight + let (discreteToKeep, discreteToIntegrate) = FloatFloatMap.partition( + ((_, v)) => keepFn(v), + discrete, + ) + let newContinousSamples = + discreteToIntegrate->FloatFloatMap.toArray + |> fmap(((k, v)) => Belt.Array.makeBy(Belt.Float.toInt(v), _ => k)) + |> Belt.Array.concatMany + let newContinuous = concat(continuous, newContinousSamples) + newContinuous |> Array.fast_sort(floatCompare) + (newContinuous, discreteToKeep) + } } } module Sorted = Floats.Sorted diff --git a/packages/website/docs/Discussions/Gallery.md b/packages/website/docs/Discussions/Gallery.md new file mode 100644 index 00000000..fee8f344 --- /dev/null +++ b/packages/website/docs/Discussions/Gallery.md @@ -0,0 +1,7 @@ +--- +sidebar_position: 6 +title: Gallery +--- + +- [Adjusting probabilities for the passage of time](https://www.lesswrong.com/s/rDe8QE5NvXcZYzgZ3/p/j8o6sgRerE3tqNWdj) by Nuño Sempere +- [GiveWell's GiveDirectly cost effectiveness analysis](https://observablehq.com/@hazelfire/givewells-givedirectly-cost-effectiveness-analysis) by Sam Nolan diff --git a/packages/website/docs/Discussions/Three-Types-Of-Distributions.md b/packages/website/docs/Discussions/Three-Formats-Of-Distributions.md similarity index 99% rename from packages/website/docs/Discussions/Three-Types-Of-Distributions.md rename to packages/website/docs/Discussions/Three-Formats-Of-Distributions.md index ffd99fc1..8ec5b88d 100644 --- a/packages/website/docs/Discussions/Three-Types-Of-Distributions.md +++ b/packages/website/docs/Discussions/Three-Formats-Of-Distributions.md @@ -1,12 +1,10 @@ --- sidebar_position: 5 +title: Three Formats of Distributions +author: Ozzie Gooen +date: 02-19-2022 --- -# Three Formats of Distributions - -_Author: Ozzie Gooen_ -_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. _Symbolic_ formats are just the math equations. `normal(5,3)` is the symbolic representation of a normal distribution. diff --git a/packages/website/docs/Features/Language.mdx b/packages/website/docs/Features/Language.mdx index e559fb60..5b66d2e2 100644 --- a/packages/website/docs/Features/Language.mdx +++ b/packages/website/docs/Features/Language.mdx @@ -1,39 +1,53 @@ --- sidebar_position: 2 +title: Language Basics --- import { SquiggleEditor } from "../../src/components/SquiggleEditor"; -# Squiggle Language +## Expressions -The squiggle language has a very simple syntax. The best way to get to understand -it is by simply looking at examples. +A distribution -## Basic Language + -As an example: +A number + + + +Arrays + + + +Records + + + +## Statements + +A statement assigns expressions to names. It looks like ` = ` -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 -and even in other notebooks! +### Functions -An export is rendered to the output view so you can see your result. - -the exports can be expressions, such as: - - - -## Functions - -Squiggle supports functions, including the rendering of functions: +We can define functions + +## See more + +- [Functions reference](https://squiggle-language.com/docs/Features/Functions) +- [Gallery](https://squiggle-language.com/docs/Discussions/Gallery) diff --git a/packages/website/docs/Features/Javascript-Libraries.md b/packages/website/docs/Features/Node-Packages.md similarity index 82% rename from packages/website/docs/Features/Javascript-Libraries.md rename to packages/website/docs/Features/Node-Packages.md index c782be6f..ab590c32 100644 --- a/packages/website/docs/Features/Javascript-Libraries.md +++ b/packages/website/docs/Features/Node-Packages.md @@ -1,13 +1,12 @@ --- sidebar_position: 3 +title: Node Packages --- -# Javascript Libraries - 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) ![npm version](https://badge.fury.io/js/@quri%2Fsquiggle-lang.svg) +- [`@quri/squiggle-components`](https://www.npmjs.com/package/@quri/squiggle-components) ![npm version](https://badge.fury.io/js/@quri%2Fsquiggle-components.svg) Types are available for both packages. @@ -23,8 +22,8 @@ argument allows you to pass an environment previously created by another `run` call. Passing this environment will mean that all previously declared variables in the previous environment will be made available. -The return type of `run` is a bit complicated, and comes from auto generated js -code that comes from rescript. I highly recommend using typescript when using +The return type of `run` is a bit complicated, and comes from auto generated `js` +code that comes from rescript. We highly recommend using typescript when using this library to help navigate the return type. ## Squiggle Components diff --git a/packages/website/docs/Internal/ProcessingConfidenceIntervals.md b/packages/website/docs/Internal/Processing-Confidence-Intervals.md similarity index 78% rename from packages/website/docs/Internal/ProcessingConfidenceIntervals.md rename to packages/website/docs/Internal/Processing-Confidence-Intervals.md index 99e72e5a..01afeb79 100644 --- a/packages/website/docs/Internal/ProcessingConfidenceIntervals.md +++ b/packages/website/docs/Internal/Processing-Confidence-Intervals.md @@ -1,6 +1,9 @@ -# Processing confidence intervals +--- +title: Processing Confidence Intervals +author: Nuño Sempere +--- -This page explains what we are doing when we take a 95% confidence interval, and we get a mean and a standard deviation from it +This page explains what we are doing when we take a 90% confidence interval, and we get a mean and a standard deviation from it. ## For normals @@ -19,10 +22,7 @@ module Normal = { We know that for a normal with mean $\mu$ and standard deviation $\sigma$, $$ - -a \cdot Normal(\mu, \sigma) = Normal(a\cdot \mu, |a|\cdot \sigma) - - +a \cdot Normal(\mu, \sigma) = Normal(a \cdot \mu, |a| \cdot \sigma) $$ We can now look at the inverse cdf of a $Normal(0,1)$. We find that the 95% point is reached at $1.6448536269514722$. ([source](https://stackoverflow.com/questions/20626994/how-to-calculate-the-inverse-of-the-normal-cumulative-distribution-function-in-p)) This means that the 90% confidence interval is $[-1.6448536269514722, 1.6448536269514722]$, which has a width of $2 \cdot 1.6448536269514722$. @@ -30,3 +30,5 @@ We can now look at the inverse cdf of a $Normal(0,1)$. We find that the 95% poin So then, if we take a $Normal(0,1)$ and we multiply it by $\frac{(high -. low)}{(2. *. 1.6448536269514722)}$, it's 90% confidence interval will be multiplied by the same amount. Then we just have to shift it by the mean to get our target normal. ## For lognormals + +TODO diff --git a/packages/website/docs/Introduction.md b/packages/website/docs/Introduction.md index ecfe7f02..91cfd919 100644 --- a/packages/website/docs/Introduction.md +++ b/packages/website/docs/Introduction.md @@ -1,10 +1,16 @@ --- sidebar_position: 1 +title: Introduction --- -# Squiggle +Squiggle is an _estimation language_, and a syntax for _calculating and expressing beliefs_ involving uncertainty. It has use cases in forecasting and writing evaluations. -Squiggle is a language for writing calculations under uncertainty. It has use -cases in forecasting and writing better evaluations. +## Get started -The best way to get started with Squiggle is to [try it out yourself](https://playground.squiggle-language.com/). +- [Gallery](https://www.squiggle-language.com/docs/Discussions/Gallery) +- [Squiggle playground](https://squiggle-language.com/playground) +- [Language basics](https://www.squiggle-language.com/docs/Features/Language) +- [Squiggle functions source of truth](https://www.squiggle-language.com/docs/Features/Functions) +- [Known bugs](https://www.squiggle-language.com/docs/Discussions/Bugs) +- [Original lesswrong sequence](https://www.lesswrong.com/s/rDe8QE5NvXcZYzgZ3) +- [Author your squiggle models as Observable notebooks](https://observablehq.com/@hazelfire/squiggle) diff --git a/packages/website/static/img/docusaurus.png b/packages/website/static/img/docusaurus.png deleted file mode 100644 index f458149e..00000000 Binary files a/packages/website/static/img/docusaurus.png and /dev/null differ diff --git a/packages/website/static/img/favicon.ico b/packages/website/static/img/favicon.ico index d318e234..d88e28c4 100644 Binary files a/packages/website/static/img/favicon.ico and b/packages/website/static/img/favicon.ico differ diff --git a/packages/website/static/img/logo.svg b/packages/website/static/img/logo.svg deleted file mode 100644 index 9db6d0d0..00000000 --- a/packages/website/static/img/logo.svg +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/packages/website/static/img/quri-logo-with-QURI-written-underneath.png b/packages/website/static/img/quri-logo-with-QURI-written-underneath.png new file mode 100644 index 00000000..14932c80 Binary files /dev/null and b/packages/website/static/img/quri-logo-with-QURI-written-underneath.png differ diff --git a/packages/website/static/img/quri-logo.png b/packages/website/static/img/quri-logo.png index 14932c80..d88e28c4 100644 Binary files a/packages/website/static/img/quri-logo.png and b/packages/website/static/img/quri-logo.png differ diff --git a/packages/website/static/img/undraw_docusaurus_mountain.svg b/packages/website/static/img/undraw_docusaurus_mountain.svg deleted file mode 100644 index 431cef2f..00000000 --- a/packages/website/static/img/undraw_docusaurus_mountain.svg +++ /dev/null @@ -1,170 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/website/static/img/undraw_docusaurus_react.svg b/packages/website/static/img/undraw_docusaurus_react.svg deleted file mode 100644 index e4170504..00000000 --- a/packages/website/static/img/undraw_docusaurus_react.svg +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/packages/website/static/img/undraw_docusaurus_tree.svg b/packages/website/static/img/undraw_docusaurus_tree.svg deleted file mode 100644 index a05cc03d..00000000 --- a/packages/website/static/img/undraw_docusaurus_tree.svg +++ /dev/null @@ -1 +0,0 @@ -docu_tree \ No newline at end of file diff --git a/yarn.lock b/yarn.lock index f9feaabc..cb1e6b3a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6155,6 +6155,11 @@ chalk@^4.0.0, chalk@^4.0.2, chalk@^4.1.0, chalk@^4.1.2: ansi-styles "^4.1.0" supports-color "^7.1.0" +chalk@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.0.1.tgz#ca57d71e82bb534a296df63bbacc4a1c22b2a4b6" + integrity sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w== + char-regex@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"