Public
Edited
Jul 6, 2023
Insert cell
Insert cell
viewof alpha = Inputs.range([0, 1], {label: tex`\alpha`, value: 0.05})
Insert cell
viewof mu = Inputs.range([0, 0.5], {label: tex`\mu`, value: 0.5})
Insert cell
Insert cell
Insert cell
Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.lineY(data, {x: "lambda", y: "type_m"})
]
})
Insert cell
sigmas = ([...new Array(1000)]).map((d, i) => (i + 1) / 1000 * 100)
Insert cell
lambdas = ([...new Array(100)]).map((d, i) => 0.25 + (i) / 100 * (3 - 0.25))
Insert cell
data = lambdas.map((lambda) => {
//const lambda = mu / sigma;
return {
//sigma: sigma,
lambda: lambda,
power: cdf.default(-z_alpha - lambda, 0, 1) + 1 - cdf.default(z_alpha - lambda, 0, 1),
type_s: cdf.default(-z_alpha - lambda, 0, 1) / (cdf.default(-z_alpha - lambda, 0, 1) + 1 - cdf.default(z_alpha - lambda, 0, 1)),
type_m: (pdf.default(lambda + z_alpha, 0, 1) + pdf.default(lambda - z_alpha, 0, 1) + lambda * (cdf.default(lambda + z_alpha, 0, 1) + cdf.default(lambda - z_alpha, 0, 1) - 1)) / (lambda * (1 - cdf.default(lambda + z_alpha, 0, 1) + cdf.default(lambda - z_alpha, 0, 1)))
};
})
Insert cell
z_alpha = quantile.default(1 - alpha, 0, 1)
Insert cell
cdf.default( 2.0, 0.0, 1.0 )
Insert cell
cdf = import('https://cdn.skypack.dev/@stdlib/stats-base-dists-normal-cdf@0.0.7?min')
Insert cell
pdf = import('https://cdn.skypack.dev/@stdlib/stats-base-dists-normal-pdf@0.0.7?min')
Insert cell
quantile = import('https://cdn.skypack.dev/@stdlib/stats-base-dists-normal-quantile@0.0.7?min')
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more