From 6a4132c955c344153ca0617ee7c962bd3bfa7db4 Mon Sep 17 00:00:00 2001 From: Ozzie Gooen Date: Mon, 13 Jun 2022 12:10:24 -0700 Subject: [PATCH] Ran format --- .../ReducerInterface_GenericDistribution.res | 3 ++- packages/website/docs/Api/Date.md | 3 ++- packages/website/docs/Api/Dictionary.md | 1 + packages/website/docs/Api/DistGeneric.mdx | 27 ++++++++++--------- packages/website/docs/Api/DistPointSet.md | 6 ++--- 5 files changed, 22 insertions(+), 18 deletions(-) diff --git a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res index 6d98d724..66ee915c 100644 --- a/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res +++ b/packages/squiggle-lang/src/rescript/ReducerInterface/ReducerInterface_GenericDistribution.res @@ -273,7 +273,8 @@ let dispatchToGenericOutput = ( | ("cdf", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Cdf(float), dist, ~env) | ("pdf", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Pdf(float), dist, ~env) | ("inv", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Inv(float), dist, ~env) - | ("quantile", [EvDistribution(dist), EvNumber(float)]) => Helpers.toFloatFn(#Inv(float), dist, ~env) + | ("quantile", [EvDistribution(dist), EvNumber(float)]) => + Helpers.toFloatFn(#Inv(float), dist, ~env) | ("toSampleSet", [EvDistribution(dist), EvNumber(float)]) => Helpers.toDistFn(ToSampleSet(Belt.Int.fromFloat(float)), dist, ~env) | ("toSampleSet", [EvDistribution(dist)]) => diff --git a/packages/website/docs/Api/Date.md b/packages/website/docs/Api/Date.md index deccdad3..9f9b9f09 100644 --- a/packages/website/docs/Api/Date.md +++ b/packages/website/docs/Api/Date.md @@ -6,7 +6,8 @@ title: Date Squiggle date types are a very simple implementation on [Javascript's Date type](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date). It's mainly here for early experimentation. There are more relevant functions for the [Duration](/docs/Api/Duration) type. ### makeFromYear -(Now ``makeDateFromYear``) + +(Now `makeDateFromYear`) ``` Date.makeFromYear: (number) => date diff --git a/packages/website/docs/Api/Dictionary.md b/packages/website/docs/Api/Dictionary.md index 0152f122..0e6dfd17 100644 --- a/packages/website/docs/Api/Dictionary.md +++ b/packages/website/docs/Api/Dictionary.md @@ -8,6 +8,7 @@ Squiggle dictionaries work similar to Python dictionaries. The syntax is similar Dictionaries are unordered and duplicates are not allowed. They are meant to be immutable, like most types in Squiggle. **Example** + ```javascript valueFromOfficeItems = { keyboard: 1, diff --git a/packages/website/docs/Api/DistGeneric.mdx b/packages/website/docs/Api/DistGeneric.mdx index 47927116..65e727ee 100644 --- a/packages/website/docs/Api/DistGeneric.mdx +++ b/packages/website/docs/Api/DistGeneric.mdx @@ -3,10 +3,10 @@ sidebar_position: 3 title: Distribution --- -Distributions are the flagship data type in Squiggle. The distribution type is a generic data type that contains one of three different formats of distributions. -These subtypes are [point set](/docs/Api/DistPointSet), [sample set](/docs/Api/DistSampleSet), and symbolic. The first two of these have a few custom functions that only work on them. You can read more about the differences between these formats [here](/docs/Discussions/Three-Formats-Of-Distributions). +Distributions are the flagship data type in Squiggle. The distribution type is a generic data type that contains one of three different formats of distributions. +These subtypes are [point set](/docs/Api/DistPointSet), [sample set](/docs/Api/DistSampleSet), and symbolic. The first two of these have a few custom functions that only work on them. You can read more about the differences between these formats [here](/docs/Discussions/Three-Formats-Of-Distributions). -Several functions below only can work on particular distribution formats. +Several functions below only can work on particular distribution formats. For example, scoring and pointwise math requires the point set format. When this happens, the types are automatically converted to the correct format. These conversions are lossy. import TOCInline from "@theme/TOCInline" @@ -15,7 +15,7 @@ import TOCInline from "@theme/TOCInline" ## Distribution Creation -These are functions for creating primative distributions. Many of these could optionally take in distributions as inputs; in these cases, Monte Carlo Sampling will be used to generate the greater distribution. This can be used for simple hierarchical models. +These are functions for creating primative distributions. Many of these could optionally take in distributions as inputs. In these cases, Monte Carlo Sampling will be used to generate the greater distribution. This can be used for simple hierarchical models. See a longer tutorial on creating distributions [here](/docs/Guides/DistributionCreation). @@ -155,7 +155,7 @@ The `to` function is an easy way to generate simple distributions using predicte If both values are above zero, a `lognormal` distribution is used. If not, a `normal` distribution is used. -``To`` is an alias for ``credibleIntervalToDistribution``. However, because of its frequent use, it is recommended to use the shorter name. +`To` is an alias for `credibleIntervalToDistribution`. However, because of its frequent use, it is recommended to use the shorter name. ``` to: (distribution|number, distribution|number) => distribution @@ -170,7 +170,6 @@ to(5,10) -5 to 5 ``` - ### mixture ``` @@ -239,8 +238,8 @@ stdev: (distribution) => number ``` ### variance -Variance. Similar to stdev, only works now on sample set distributions. +Variance. Similar to stdev, only works now on sample set distributions. ``` variance: (distribution) => number @@ -305,6 +304,7 @@ toPointSet(normal(5, 2)) ``` ### toSampleSet + **TODO: Will soon be called "SampleSet.make"** Converts a distribution to the sampleSet format, with n samples @@ -451,7 +451,7 @@ integralSum(normal(5, 2)) Regular arithmetic operations cover the basic mathematical operations on distributions. They work much like their equivalent operations on numbers. -The infixes ``+``,``-``, ``*``, ``/``, ``^``, ``-`` are supported for addition, subtraction, multiplication, division, power, and unaryMinus. +The infixes `+`,`-`, `*`, `/`, `^`, `-` are supported for addition, subtraction, multiplication, division, power, and unaryMinus. ```javascript pointMass(5 + 10) == pointMass(5) + pointMass(10) @@ -466,11 +466,12 @@ add: (distributionLike, distributionLike) => distribution **Examples** ```javascript -normal(0,1) + normal(1,3) // returns normal(1, 3.16...) -add(normal(0,1), normal(1,3)) // returns normal(1, 3.16...) +normal(0, 1) + normal(1, 3) // returns normal(1, 3.16...) +add(normal(0, 1), normal(1, 3)) // returns normal(1, 3.16...) ``` ### sum + **Todo: Not yet implemented for distributions** ``` @@ -480,7 +481,7 @@ sum: (list) => distribution **Examples** ```javascript -sum([normal(0,1), normal(1,3), uniform(10,1)]) +sum([normal(0, 1), normal(1, 3), uniform(10, 1)]) ``` ### multiply @@ -540,8 +541,8 @@ unaryMinus: (distribution) => distribution **Examples** ```javascript --(normal(5,2)) // same as normal(-5, 2) -unaryMinus(normal(5,2)) // same as normal(-5, 2) +-normal(5, 2) // same as normal(-5, 2) +unaryMinus(normal(5, 2)) // same as normal(-5, 2) ``` ## Pointwise Arithmetic Operations diff --git a/packages/website/docs/Api/DistPointSet.md b/packages/website/docs/Api/DistPointSet.md index eb3f8b93..6fabd158 100644 --- a/packages/website/docs/Api/DistPointSet.md +++ b/packages/website/docs/Api/DistPointSet.md @@ -7,7 +7,6 @@ title: Point Set Distribution Converts the distribution in question into a point set distribution. If the distribution is symbolic, then it does this by taking the quantiles. If the distribution is a sample set, then it uses a version of kernel density estimation to approximate the point set format. One complication of this latter process is that if there is a high proportion of overlapping samples (samples that are exactly the same as each other), it will convert these samples into discrete point masses. Eventually we'd like to add further methods to help adjust this process. - ``` PointSet.make: (distribution) => pointSetDist ``` @@ -28,10 +27,11 @@ PointSet.makeContinuous([ { x: 1, y: 0.2 }, { x: 2, y: 0.15 }, { x: 3, y: 0.1 }, -]) +]); ``` ### makeDiscrete + **TODO: Now called "toDiscretePointSet"** Converts a set of x-y coordinates directly into a discrete distribution. @@ -46,5 +46,5 @@ PointSet.makeDiscrete([ { x: 1, y: 0.2 }, { x: 2, y: 0.15 }, { x: 3, y: 0.1 }, -]) +]); ```