diff --git a/packages/squiggle-lang/src/fr/scale.ts b/packages/squiggle-lang/src/fr/scale.ts index 45d00cd627..e067de44dc 100644 --- a/packages/squiggle-lang/src/fr/scale.ts +++ b/packages/squiggle-lang/src/fr/scale.ts @@ -107,6 +107,11 @@ export const library = [ name: "symlog", output: "Scale", examples: [`Scale.symlog({ min: -10, max: 10 })`], + description: `Symmetric log scale. Useful for plotting data that includes zero or negative values. + +The function accepts an additional \`constant\` parameter, used as follows: \`Scale.symlog({constant: 0.1})\`. This parameter allows you to allocate more pixel space to data with lower or higher absolute values. By adjusting this constant, you effectively control the scale's focus, shifting it between smaller and larger values. For more detailed information on this parameter, refer to the [D3 Documentation](https://d3js.org/d3-scale/symlog). + +The default value for \`constant\` is \`${0.0001}\`.`, // I tried to set this to the default value in the code, but this gave webpack in the Website. definitions: [ makeDefinition( [ @@ -144,6 +149,9 @@ export const library = [ name: "power", output: "Scale", examples: [`Scale.power({ min: 1, max: 100, exponent: 0.1 })`], + description: `Power scale. Accepts an extra \`exponent\` parameter, like, \`Scale.power({exponent: 2, min: 0, max: 100})\`. + +The default value for \`exponent\` is \`${0.1}\`.`, definitions: [ makeDefinition( [ @@ -181,6 +189,8 @@ export const library = [ name: "date", output: "Scale", examples: ["Scale.date({ min: Date(2022), max: Date(2025) })"], + description: + "Scale for dates. Only works on Date values. Is a linear scale under the hood.", definitions: [ makeDefinition( [dateDict], diff --git a/packages/squiggle-lang/src/fr/sym.ts b/packages/squiggle-lang/src/fr/sym.ts index 82b218fabc..a39b776c6f 100644 --- a/packages/squiggle-lang/src/fr/sym.ts +++ b/packages/squiggle-lang/src/fr/sym.ts @@ -173,6 +173,8 @@ export const library: FRFunction[] = [ name: "pointMass", requiresNamespace: false, examples: ["pointMass(0.5)"], + description: + "Point mass distributions are already symbolic, so you can use the regular `pointMass` function.", definitions: [ makeDefinition([frNumber], frDistSymbolic, ([v]) => { const result = SymbolicDist.PointMass.make(v); diff --git a/packages/website/.gitignore b/packages/website/.gitignore index 1bdf4526dd..a5ece619c5 100644 --- a/packages/website/.gitignore +++ b/packages/website/.gitignore @@ -9,5 +9,7 @@ /src/pages/docs/Api/Dict.mdx /src/pages/docs/Api/SampleSet.mdx /src/pages/docs/Api/PointSet.mdx +/src/pages/docs/Api/Sym.mdx +/src/pages/docs/Api/Scale.mdx /src/pages/docs/Ecosystem/LLMPrompt.md /public/llms/documentationBundle.txt \ No newline at end of file diff --git a/packages/website/scripts/generateModulePages.mjs b/packages/website/scripts/generateModulePages.mjs index 3ee145831c..07b44722ea 100644 --- a/packages/website/scripts/generateModulePages.mjs +++ b/packages/website/scripts/generateModulePages.mjs @@ -112,6 +112,21 @@ All regular distribution function work on sample set distributions. In addition, One complication is that it's possible to represent invalid probability distributions in the point set format. For example, you can represent shapes with negative values, or shapes that are not normalized.`, }, + { + name: "Sym", + description: + "The Sym module provides functions to create some common symbolic distributions.", + imports: `import { FnDocumentationFromName } from "@quri/squiggle-components";`, + intro: `Symbolic Distributions. All these functions match the functions for creating sample set distributions, but produce symbolic distributions instead. Symbolic distributions won't capture correlations, but are more performant than sample distributions.`, + }, + { + name: "Scale", + description: "Scales for plots.", + imports: `import { FnDocumentationFromName } from "@quri/squiggle-components";`, + intro: `Chart axes in [plots](./Plot.mdx) can be scaled using the following functions. Each scale function accepts optional min and max value. Power scale accepts an extra exponent parameter. + +Squiggle uses D3 for the tick formats. You can read about d3 tick formats [here](https://github.com/d3/d3-format).`, + }, ]; function toMarkdownDefinitions(definitions) { diff --git a/packages/website/src/pages/docs/Api/Scale.mdx b/packages/website/src/pages/docs/Api/Scale.mdx deleted file mode 100644 index e9866cb722..0000000000 --- a/packages/website/src/pages/docs/Api/Scale.mdx +++ /dev/null @@ -1,62 +0,0 @@ -# Scale - -Chart axes in [plots](./Plot.mdx) can be scaled using the following functions. Each scale function accepts optional min and max value. Power scale accepts an extra exponent parameter. - -We use D3 for the tick formats. You can read about custom tick formats [here](https://github.com/d3/d3-format). - -### Scale.log - -``` -Scale.log: ({ - min: number, - max: number, - tickFormat: string, - title: string -}) => scale -``` - -### Scale.linear - -``` -Scale.linear: ({ - min: number, - max: number, - tickFormat: string, - title: string -}) => scale -``` - -### Scale.symlog - -Symmetric log scale. Useful for plotting data that includes zero or negative values. - -The function accepts an additional `constant` parameter, used as follows: `Scale.symlog({constant: 0.1})`. This parameter allows you to allocate more pixel space to data with lower or higher absolute values. By adjusting this constant, you effectively control the scale's focus, shifting it between smaller and larger values. For more detailed information on this parameter, refer to the [D3 Documentation](https://d3js.org/d3-scale/symlog). - -The default value for `constant` is `1`. - - -``` -Scale.symlog: ({ - min: number, - max: number, - tickFormat: string, - title: string, - constant: number -}) => scale -``` - -### Scale.power - -Power scale. Accepts an extra `exponent` parameter, like, `Scale.power({exponent: 2, min: 0, max: 100})`. - -The default value for `exponent` is `0.1`. - -``` -Scale.power: ({ - min: number, - max: number, - tickFormat: string, - title: string, - exponent: number -}) => scale -``` diff --git a/packages/website/src/pages/docs/Api/Sym.mdx b/packages/website/src/pages/docs/Api/Sym.mdx deleted file mode 100644 index 38f74b565a..0000000000 --- a/packages/website/src/pages/docs/Api/Sym.mdx +++ /dev/null @@ -1,29 +0,0 @@ ---- -description: The Sym module provides functions to create some common symbolic distributions. ---- - -# Sym - -All these functions match the functions for creating [sample set distributions](./Dist.mdx). - -### Sym.normal - -### Sym.lognormal - -### Sym.uniform - -### Sym.beta - -### Sym.cauchy - -### Sym.gamma - -### Sym.logistic - -### Sym.exponential - -### Sym.bernoulli - -### pointMass - -### Sym.triangular