diff --git a/apps/shared.universal.i18n b/apps/shared.universal.i18n index b313ff93c..47b8ac66d 100644 --- a/apps/shared.universal.i18n +++ b/apps/shared.universal.i18n @@ -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)" diff --git a/apps/toolbox.de.i18n b/apps/toolbox.de.i18n index eff98dbe8..b55853754 100644 --- a/apps/toolbox.de.i18n +++ b/apps/toolbox.de.i18n @@ -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 Evaluation InvNormNode::templatedApproximate(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const { Evaluation aEvaluation = childAtIndex(0)->approximate(T(), context, complexFormat, angleUnit); Evaluation muEvaluation = childAtIndex(1)->approximate(T(), context, complexFormat, angleUnit); - Evaluation varEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit); + Evaluation 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::Builder(NormalDistribution::CumulativeDistributiveInverseForProbability(a, mu, sigma)); diff --git a/poincare/src/norm_cdf.cpp b/poincare/src/norm_cdf.cpp index 52c8f1761..2775cc418 100644 --- a/poincare/src/norm_cdf.cpp +++ b/poincare/src/norm_cdf.cpp @@ -27,11 +27,11 @@ template Evaluation NormCDFNode::templatedApproximate(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const { Evaluation aEvaluation = childAtIndex(0)->approximate(T(), context, complexFormat, angleUnit); Evaluation muEvaluation = childAtIndex(1)->approximate(T(), context, complexFormat, angleUnit); - Evaluation varEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit); + Evaluation 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::Builder(NormalDistribution::CumulativeDistributiveFunctionAtAbscissa(a, mu, sigma)); diff --git a/poincare/src/norm_cdf2.cpp b/poincare/src/norm_cdf2.cpp index b655a10de..625451406 100644 --- a/poincare/src/norm_cdf2.cpp +++ b/poincare/src/norm_cdf2.cpp @@ -28,12 +28,12 @@ Evaluation NormCDF2Node::templatedApproximate(Context * context, Preferences: Evaluation aEvaluation = childAtIndex(0)->approximate(T(), context, complexFormat, angleUnit); Evaluation bEvaluation = childAtIndex(1)->approximate(T(), context, complexFormat, angleUnit); Evaluation muEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit); - Evaluation varEvaluation = childAtIndex(3)->approximate(T(), context, complexFormat, angleUnit); + Evaluation 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::Undefined(); diff --git a/poincare/src/norm_pdf.cpp b/poincare/src/norm_pdf.cpp index af19c69c6..bb3ccee3f 100644 --- a/poincare/src/norm_pdf.cpp +++ b/poincare/src/norm_pdf.cpp @@ -27,11 +27,11 @@ template Evaluation NormPDFNode::templatedApproximate(Context * context, Preferences::ComplexFormat complexFormat, Preferences::AngleUnit angleUnit) const { Evaluation xEvaluation = childAtIndex(0)->approximate(T(), context, complexFormat, angleUnit); Evaluation muEvaluation = childAtIndex(1)->approximate(T(), context, complexFormat, angleUnit); - Evaluation varEvaluation = childAtIndex(2)->approximate(T(), context, complexFormat, angleUnit); + Evaluation 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::Builder(NormalDistribution::EvaluateAtAbscissa(x, mu, sigma)); diff --git a/poincare/test/approximation.cpp b/poincare/test/approximation.cpp index ac54076c8..7f08c06b0 100644 --- a/poincare/test/approximation.cpp +++ b/poincare/test/approximation.cpp @@ -295,8 +295,8 @@ QUIZ_CASE(poincare_approximation_function) { assert_expression_approximates_to("invbinom(0.9647324002, 15, 0.7)", "13"); assert_expression_approximates_to("invbinom(0.9647324002, 15, 0.7)", "13"); - assert_expression_approximates_to("invnorm(0.56, 1.3, 5.76)", "1.662326"); - //assert_expression_approximates_to("invnorm(0.56, 1.3, 5.76)", "1.6623258450088"); FIXME precision error + assert_expression_approximates_to("invnorm(0.56, 1.3, 2.4)", "1.662326"); + //assert_expression_approximates_to("invnorm(0.56, 1.3, 2.4)", "1.6623258450088"); FIXME precision error assert_expression_approximates_to("ln(2)", "0.6931472"); assert_expression_approximates_to("ln(2)", "6.9314718055995ᴇ-1"); @@ -304,17 +304,19 @@ QUIZ_CASE(poincare_approximation_function) { assert_expression_approximates_to("log(2)", "0.30103"); assert_expression_approximates_to("log(2)", "3.0102999566398ᴇ-1"); - assert_expression_approximates_to("normcdf(1.2, 3.4, 31.36)", "0.3472125"); - assert_expression_approximates_to("normcdf(1.2, 3.4, 31.36)", "3.4721249841587ᴇ-1"); - assert_expression_approximates_to("normcdf(-1ᴇ99,3.4,31.36)", "0"); - assert_expression_approximates_to("normcdf(1ᴇ99,3.4,31.36)", "1"); + assert_expression_approximates_to("normcdf(5, 7, 0.3162)", "1.265256ᴇ-10"); + + assert_expression_approximates_to("normcdf(1.2, 3.4, 5.6)", "0.3472125"); + assert_expression_approximates_to("normcdf(1.2, 3.4, 5.6)", "3.4721249841587ᴇ-1"); + assert_expression_approximates_to("normcdf(-1ᴇ99,3.4,5.6)", "0"); + assert_expression_approximates_to("normcdf(1ᴇ99,3.4,5.6)", "1"); assert_expression_approximates_to("normcdf(-6,0,1)", "0"); assert_expression_approximates_to("normcdf(6,0,1)", "1"); - assert_expression_approximates_to("normcdf2(0.5, 3.6, 1.3, 11.56)", "0.3436388"); - assert_expression_approximates_to("normcdf2(0.5, 3.6, 1.3, 11.56)", "3.4363881299147ᴇ-1"); + assert_expression_approximates_to("normcdf2(0.5, 3.6, 1.3, 3.4)", "0.3436388"); + assert_expression_approximates_to("normcdf2(0.5, 3.6, 1.3, 3.4)", "3.4363881299147ᴇ-1"); - assert_expression_approximates_to("normpdf(1.2, 3.4, 31.36)", "0.06594901"); + assert_expression_approximates_to("normpdf(1.2, 3.4, 5.6)", "0.06594901"); assert_expression_approximates_to("permute(10, 4)", "5040"); assert_expression_approximates_to("permute(10, 4)", "5040"); diff --git a/poincare/test/simplification.cpp b/poincare/test/simplification.cpp index b0124a85a..0412d5583 100644 --- a/poincare/test/simplification.cpp +++ b/poincare/test/simplification.cpp @@ -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");