The normal_prob() command produces probabilities greater than 1 beyond +/- 3.7 sd
by tim Payer - Number of replies: 4Re: The normal_prob() command produces probabilities greater than 1 beyond +/- 3.7 sd
by Alex Jordan -The actual value of P(Z < -3.72) is:
0.0000996114
which in scientific notation is
9.96114e-5
And if something interprets "e" as Euler's constant and the "-" as subtraction, the above is:
22.077
which is close to what you report here. So I think that (a) there is a small rounding error in play, and (b) more importantly you have something at some point in your code that sends something close to "9.96114e-5" as a string to a MathObject constructor, where the "e" is interpreted as Euler's constant and the "-" as subtraction.
Fixing (b) should be easy. Review your problem code for the chain of commands that produces the 22.1828, and edit it to prevent the string interpolation.
(a) might be an issue built into the library that PGstatisticsmacros relies on. If addressing (b) is not enough for your purposes, post more details and we can continue working to make that function perform better.
Re: The normal_prob() command produces probabilities greater than 1 beyond +/- 3.7 sd
by tim Payer -Thank you Alex, that makes sense.
Here is the adaptation that I used to prevent the reading of scientific notation as and operation using "e" as a multiple, and the exponent as a term to be added or subtracted:
## Testing p-value ranges:
$z = Compute("-4.89");
$q = normal_prob(-infty, $z, mean=>0, deviation=>1);
$qz = Real($q);
$p = Compute("$qz")->with(
tolType => 'absolute',
tolerance => .00001,
);
###
Squeezing in a Real() command prevents the reading of Sci-Fi notation as an operation.
Now the lower and upper limit of extreme probability values for Z-scores are: (-4.89 < Z < 7.03).
Outside of these values the probabilities of Z-scores on the normal_prob() command all go to zero. This is a big improvement over the Z-values less than Z = -3.7 returning probabilities with absolute values larger than one.
Best, tim
Re: The normal_prob() command produces probabilities greater than 1 beyond +/- 3.7 sd
by Danny Glin -You can simplify your code a bit here. Because "Real" already creates a MathObject the extra "Compute" isn't really doing anything.
You could skip to
$p = Real($q)->with(
tolType => 'absolute',
tolerance => .00001,
);
Or even
$p = Real (normal_prob(-infty, $z, mean=>0, deviation=>1))->with(
tolType => 'absolute',
tolerance => .00001,
);
Also, you don't need to convert your z-score to a MathObject (unless you are using it elsewhere in the problem), so the Compute call on $z isn't necessary for the code snippet you posted.Re: The normal_prob() command produces probabilities greater than 1 beyond +/- 3.7 sd
by tim Payer -Thank you Danny!
That will help streamline the code block.
Best, Tim