MCPcopy Create free account
hub / github.com/microsoft/SandDance / uniform

Function uniform

docs/app/js/sanddance-app.js:119600–119625  ·  view source on GitHub ↗
(min, max)

Source from the content-addressed store, hash-verified

119598 return p >= 0 && p <= 1 ? min + p * (max - min) : NaN;
119599}
119600function uniform(min, max) {
119601 let a, b;
119602 const dist = {
119603 min (_) {
119604 if (arguments.length) {
119605 a = _ || 0;
119606 return dist;
119607 } else return a;
119608 },
119609 max (_) {
119610 if (arguments.length) {
119611 b = _ == null ? 1 : _;
119612 return dist;
119613 } else return b;
119614 },
119615 sample: ()=>sampleUniform(a, b),
119616 pdf: (value)=>densityUniform(value, a, b),
119617 cdf: (value)=>cumulativeUniform(value, a, b),
119618 icdf: (p)=>quantileUniform(p, a, b)
119619 };
119620 if (max == null) {
119621 max = min == null ? 1 : min;
119622 min = 0;
119623 }
119624 return dist.min(min).max(max);
119625}
119626// Ordinary Least Squares
119627function ols(uX, uY, uXY, uX2) {
119628 const delta = uX2 - uX * uX, slope = Math.abs(delta) < 1e-24 ? 0 : (uXY - uX * uY) / delta, intercept = uY - slope * uX;

Callers

nothing calls this directly

Calls 6

sampleUniformFunction · 0.70
densityUniformFunction · 0.70
cumulativeUniformFunction · 0.70
quantileUniformFunction · 0.70
maxMethod · 0.45
minMethod · 0.45

Tested by

no test coverage detected