[Toolbox] Changed the required parameters for normal_distributions

Changed the parameter σ2 to σ. This is now consistant with the
probability app

Change-Id: I96101ba158cebef972e536cfa5cc1b2da71b543d
This commit is contained in:
Arthur Camouseigt
2020-07-01 16:33:44 +02:00
committed by Émilie Feral
parent 6072ffd848
commit 997c103fba
14 changed files with 52 additions and 50 deletions

View File

@@ -114,7 +114,7 @@ IntCommand = "int(\x11,x,\x11,\x11)"
IntCommandWithArg = "int(f(x),x,a,b)"
InvBinomialCommandWithArg = "invbinom(a,n,p)"
InverseCommandWithArg = "inverse(M)"
InvNormCommandWithArg = "invnorm(a,μ,σ2)"
InvNormCommandWithArg = "invnorm(a,μ,σ)"
InvSortCommandWithArg = "sort>(L)"
K = "k"
Lambda = "λ"
@@ -127,9 +127,9 @@ MaxCommandWithArg = "max(L)"
MinCommandWithArg = "min(L)"
Mu = "μ"
N = "n"
NormCDFCommandWithArg = "normcdf(a,μ,σ2)"
NormCDF2CommandWithArg = "normcdf2(a,b,μ,σ2)"
NormPDFCommandWithArg = "normpdf(x,μ,σ2)"
NormCDFCommandWithArg = "normcdf(a,μ,σ)"
NormCDF2CommandWithArg = "normcdf2(a,b,μ,σ)"
NormPDFCommandWithArg = "normpdf(x,μ,σ)"
PermuteCommandWithArg = "permute(n,r)"
P = "p"
Prediction95CommandWithArg = "prediction95(p,n)"

View File

@@ -155,10 +155,10 @@ RandomAndApproximation = "Zufall und Näherung"
RandomFloat = "Dezimalzahl in [0,1]"
RandomInteger = "Zufällige ganze Zahl in [a,b]"
PrimeFactorDecomposition = "Primfaktorzerlegung"
NormCDF = "P(X<a) wo X folgt N(μ,σ2)"
NormCDF2 = "P(a<X<b) wo X folgt N(μ,σ2)"
InvNorm = "m wo P(X<m)=a und X folgt N(μ,σ2)"
NormPDF = "Wahrscheinlichkeitsdichte N(μ,σ2)"
NormCDF = "P(X<a) wo X folgt N(μ,σ)"
NormCDF2 = "P(a<X<b) wo X folgt N(μ,σ)"
InvNorm = "m wo P(X<m)=a und X folgt N(μ,σ)"
NormPDF = "Wahrscheinlichkeitsdichte N(μ,σ)"
BinomialPDF = "P(X=m) wo X folgt B(n,p)"
BinomialCDF = "P(X<=m) wo X folgt B(n,p)"
InvBinomial = "m wo P(X<=m)=a und X folgt B(n,p)"

View File

@@ -155,10 +155,10 @@ RandomAndApproximation = "Random and approximation"
RandomFloat = "Floating point number in [0,1["
RandomInteger = "Random integer in [a,b]"
PrimeFactorDecomposition = "Integer factorization"
NormCDF = "P(X<a) where X follows N(μ,σ2)"
NormCDF2 = "P(a<X<b) where X follows N(μ,σ2)"
InvNorm = "m where P(X<m)=a, X follows N(μ,σ2)"
NormPDF = "Probability density of N(μ,σ2)"
NormCDF = "P(X<a) where X follows N(μ,σ)"
NormCDF2 = "P(a<X<b) where X follows N(μ,σ)"
InvNorm = "m where P(X<m)=a, X follows N(μ,σ)"
NormPDF = "Probability density of N(μ,σ)"
BinomialPDF = "P(X=m) where X follows B(n,p)"
BinomialCDF = "P(X<=m) where X follows B(n,p)"
InvBinomial = "m where P(X<=m)=a, X follows B(n,p)"

View File

@@ -155,10 +155,10 @@ RandomAndApproximation = "Aleatorio y aproximación"
RandomFloat = "Número decimal en [0,1["
RandomInteger = "Entero aleatorio en [a,b]"
PrimeFactorDecomposition = "Factorización de enteros"
NormCDF = "P(X<a) donde X sigue N(μ,σ2)"
NormCDF2 = "P(a<X<b) donde X sigue N(μ,σ2)"
InvNorm = "m donde P(X<m)=a y X sigue N(μ,σ2)"
NormPDF = "Densidad de probabilidad de N(μ,σ2)"
NormCDF = "P(X<a) donde X sigue N(μ,σ)"
NormCDF2 = "P(a<X<b) donde X sigue N(μ,σ)"
InvNorm = "m donde P(X<m)=a y X sigue N(μ,σ)"
NormPDF = "Densidad de probabilidad de N(μ,σ)"
BinomialPDF = "P(X=m) donde X sigue B(n,p)"
BinomialCDF = "P(X<=m) donde X sigue B(n,p)"
InvBinomial = "m donde P(X<=m)=a y X sigue B(n,p)"

View File

@@ -155,10 +155,10 @@ RandomAndApproximation = "Aléatoire et approximation"
RandomFloat = "Nombre décimal dans [0;1["
RandomInteger = "Entier aléatoire dans [a;b]"
PrimeFactorDecomposition = "Décomposition en facteurs premiers"
NormCDF = "P(X<a) où X suit N(μ,σ2)"
NormCDF2 = "P(a<X<b) où X suit N(μ,σ2)"
InvNorm = "m où P(X<m)=a et X suit N(μ,σ2)"
NormPDF = "Fonction densité N(μ,σ2)"
NormCDF = "P(X<a) où X suit N(μ,σ)"
NormCDF2 = "P(a<X<b) où X suit N(μ,σ)"
InvNorm = "m où P(X<m)=a et X suit N(μ,σ)"
NormPDF = "Fonction densité N(μ,σ)"
BinomialPDF = "P(X=m) où X suit B(n,p)"
BinomialCDF = "P(X<=m) où X suit B(n,p)"
InvBinomial = "m où P(X<=m)=a et X suit B(n,p)"

View File

@@ -155,10 +155,10 @@ RandomAndApproximation = "Aleatorietà e approssimazione"
RandomFloat = "Decimale aleatorio tra [0,1["
RandomInteger = "Intero aleatorio tra [a,b]"
PrimeFactorDecomposition = "Scomposizione in fattori primi"
NormCDF = "P(X<a) dove X segue N(μ,σ2)"
NormCDF2 = "P(a<X<b) dove X segue N(μ,σ2)"
InvNorm = "m dove P(X<m)=a e X segue N(μ,σ2)"
NormPDF = "Funzione di densità N(μ,σ2)"
NormCDF = "P(X<a) dove X segue N(μ,)"
NormCDF2 = "P(a<X<b) dove X segue N(μ,σ)"
InvNorm = "m dove P(X<m)=a e X segue N(μ,σ)"
NormPDF = "Funzione di densità N(μ,σ)"
BinomialPDF = "P(X=m) dove X segue B(n,p)"
BinomialCDF = "P(X<=m) dove X segue B(n,p)"
InvBinomial = "m dove P(X<=m)=a e X segue B(n,p)"

View File

@@ -155,10 +155,10 @@ RandomAndApproximation = "Willekeurig en benadering"
RandomFloat = "Zwevendekommagetal in [0,1["
RandomInteger = "Willekeurig geheel getal in [a,b]"
PrimeFactorDecomposition = "Ontbinden in factoren"
NormCDF = "P(X<a) waar X volgt N(μ,σ2)"
NormCDF2 = "P(a<X<b) waar X volgt N(μ,σ2)"
InvNorm = "m waar P(X<m)=a, X volgt N(μ,σ2)"
NormPDF = "Kansdichtheid van N(μ,σ2)"
NormCDF = "P(X<a) waar X volgt N(μ,)"
NormCDF2 = "P(a<X<b) waar X volgt N(μ,σ)"
InvNorm = "m waar P(X<m)=a, X volgt N(μ,σ)"
NormPDF = "Kansdichtheid van N(μ,σ)"
BinomialPDF = "P(X=m) waar X volgt B(n,p)"
BinomialCDF = "P(X<=m) waar X volgt B(n,p)"
InvBinomial = "m waar P(X<=m)=a, X volgt B(n,p)"

View File

@@ -155,10 +155,10 @@ RandomAndApproximation = "Aleatório e aproximação"
RandomFloat = "Número decimal em [0,1["
RandomInteger = "Inteiro aleatório em [a,b]"
PrimeFactorDecomposition = "Fatorização de inteiros"
NormCDF = "P(X<a) onde X segue N(μ,σ2)"
NormCDF2 = "P(a<X<b) onde X segue N(μ,σ2)"
InvNorm = "m onde P(X<m)=a e X segue N(μ,σ2)"
NormPDF = "Densidade de probabilidade de N(μ,σ2)"
NormCDF = "P(X<a) onde X segue N(μ,σ)"
NormCDF2 = "P(a<X<b) onde X segue N(μ,σ)"
InvNorm = "m onde P(X<m)=a e X segue N(μ,σ)"
NormPDF = "Densidade de probabilidade de N(μ,σ)"
BinomialPDF = "P(X=m) onde X segue B(n,p)"
BinomialCDF = "P(X<=m) onde X segue B(n,p)"
InvBinomial = "m onde P(X<=m)=a e X segue B(n,p)"

View File

@@ -29,11 +29,11 @@ template<typename T>
Evaluation<T> InvNormNode::templatedApproximate(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const {
Evaluation<T> aEvaluation = childAtIndex(0)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> muEvaluation = childAtIndex(1)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> varEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> sigmaEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit);
T a = aEvaluation.toScalar();
T mu = muEvaluation.toScalar();
T sigma = std::sqrt(varEvaluation.toScalar());
T sigma = sigmaEvaluation.toScalar();
// CumulativeDistributiveInverseForProbability handles bad mu and var values
return Complex<T>::Builder(NormalDistribution::CumulativeDistributiveInverseForProbability<T>(a, mu, sigma));

View File

@@ -27,11 +27,11 @@ template<typename T>
Evaluation<T> NormCDFNode::templatedApproximate(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const {
Evaluation<T> aEvaluation = childAtIndex(0)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> muEvaluation = childAtIndex(1)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> varEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> sigmaEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit);
const T a = aEvaluation.toScalar();
const T mu = muEvaluation.toScalar();
const T sigma = std::sqrt(varEvaluation.toScalar());
const T sigma = sigmaEvaluation.toScalar();
// CumulativeDistributiveFunctionAtAbscissa handles bad mu and var values
return Complex<T>::Builder(NormalDistribution::CumulativeDistributiveFunctionAtAbscissa(a, mu, sigma));

View File

@@ -28,12 +28,12 @@ Evaluation<T> NormCDF2Node::templatedApproximate(Context * context, Preferences:
Evaluation<T> aEvaluation = childAtIndex(0)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> bEvaluation = childAtIndex(1)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> muEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> varEvaluation = childAtIndex(3)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> sigmaEvaluation = childAtIndex(3)->approximate(T(), context, complexFormat, angleUnit);
T a = aEvaluation.toScalar();
T b = bEvaluation.toScalar();
T mu = muEvaluation.toScalar();
T sigma = std::sqrt(varEvaluation.toScalar());
T sigma = sigmaEvaluation.toScalar();
if (std::isnan(a) || std::isnan(b) || !NormalDistribution::MuAndSigmaAreOK(mu,sigma)) {
return Complex<T>::Undefined();

View File

@@ -27,11 +27,11 @@ template<typename T>
Evaluation<T> NormPDFNode::templatedApproximate(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const {
Evaluation<T> xEvaluation = childAtIndex(0)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> muEvaluation = childAtIndex(1)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> varEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit);
Evaluation<T> sigmaEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit);
T x = xEvaluation.toScalar();
T mu = muEvaluation.toScalar();
T sigma = std::sqrt(varEvaluation.toScalar());
T sigma = sigmaEvaluation.toScalar();
// EvaluateAtAbscissa handles bad mu and var values
return Complex<T>::Builder(NormalDistribution::EvaluateAtAbscissa(x, mu, sigma));

View File

@@ -295,8 +295,8 @@ QUIZ_CASE(poincare_approximation_function) {
assert_expression_approximates_to<float>("invbinom(0.9647324002, 15, 0.7)", "13");
assert_expression_approximates_to<double>("invbinom(0.9647324002, 15, 0.7)", "13");
assert_expression_approximates_to<float>("invnorm(0.56, 1.3, 5.76)", "1.662326");
//assert_expression_approximates_to<double>("invnorm(0.56, 1.3, 5.76)", "1.6623258450088"); FIXME precision error
assert_expression_approximates_to<float>("invnorm(0.56, 1.3, 2.4)", "1.662326");
//assert_expression_approximates_to<double>("invnorm(0.56, 1.3, 2.4)", "1.6623258450088"); FIXME precision error
assert_expression_approximates_to<float>("ln(2)", "0.6931472");
assert_expression_approximates_to<double>("ln(2)", "6.9314718055995ᴇ-1");
@@ -304,17 +304,19 @@ QUIZ_CASE(poincare_approximation_function) {
assert_expression_approximates_to<float>("log(2)", "0.30103");
assert_expression_approximates_to<double>("log(2)", "3.0102999566398ᴇ-1");
assert_expression_approximates_to<float>("normcdf(1.2, 3.4, 31.36)", "0.3472125");
assert_expression_approximates_to<double>("normcdf(1.2, 3.4, 31.36)", "3.4721249841587ᴇ-1");
assert_expression_approximates_to<float>("normcdf(-1ᴇ99,3.4,31.36)", "0");
assert_expression_approximates_to<float>("normcdf(1ᴇ99,3.4,31.36)", "1");
assert_expression_approximates_to<float>("normcdf(5, 7, 0.3162)", "1.265256ᴇ-10");
assert_expression_approximates_to<float>("normcdf(1.2, 3.4, 5.6)", "0.3472125");
assert_expression_approximates_to<double>("normcdf(1.2, 3.4, 5.6)", "3.4721249841587ᴇ-1");
assert_expression_approximates_to<float>("normcdf(-1ᴇ99,3.4,5.6)", "0");
assert_expression_approximates_to<float>("normcdf(1ᴇ99,3.4,5.6)", "1");
assert_expression_approximates_to<float>("normcdf(-6,0,1)", "0");
assert_expression_approximates_to<float>("normcdf(6,0,1)", "1");
assert_expression_approximates_to<float>("normcdf2(0.5, 3.6, 1.3, 11.56)", "0.3436388");
assert_expression_approximates_to<double>("normcdf2(0.5, 3.6, 1.3, 11.56)", "3.4363881299147ᴇ-1");
assert_expression_approximates_to<float>("normcdf2(0.5, 3.6, 1.3, 3.4)", "0.3436388");
assert_expression_approximates_to<double>("normcdf2(0.5, 3.6, 1.3, 3.4)", "3.4363881299147ᴇ-1");
assert_expression_approximates_to<float>("normpdf(1.2, 3.4, 31.36)", "0.06594901");
assert_expression_approximates_to<float>("normpdf(1.2, 3.4, 5.6)", "0.06594901");
assert_expression_approximates_to<float>("permute(10, 4)", "5040");
assert_expression_approximates_to<double>("permute(10, 4)", "5040");

View File

@@ -344,7 +344,7 @@ QUIZ_CASE(poincare_simplification_units) {
assert_parsed_expression_simplify_to("inf×_s", "inf×_s");
assert_parsed_expression_simplify_to("-inf×_s", "-inf×_s");
assert_parsed_expression_simplify_to("2_s+3_s-5_s", "0×_s");
assert_parsed_expression_simplify_to("normcdf(0,20,3)×_s", "0×_s");
assert_parsed_expression_simplify_to("normcdf(0,20,3)×_s", "13.083978345207×_ps");
assert_parsed_expression_simplify_to("log(0)×_s", "-inf×_s");
assert_parsed_expression_simplify_to("log(undef)*_s", "undef");