## WeBWorK Main Forum

### The normal_prob() command produces probabilities greater than 1 beyond +/- 3.7 sd

by tim Payer -
Number of replies: 4

I was editing some webwork problems for probability and thought I had a faulty variable as I was getting p-values that exceed one.

It turns out that it is the normal_prob() command.

Apparently the threshold for valid Z-scores to use for inputs is within  plus/minus 3.71 standard deviations.

Using
$pv = normal_prob(-infty,$zh1, mean=>0, deviation=>1);

Results in the associated output:

P(Z < -3.71) = 0.000104  Correct
P(Z < -3.72) = 22.1828
P(Z < -3.73) = 21.0955
P(Z < -3.74) = 20.008
P(Z < -3.75) = 18.9209
P(Z < -3.8) = 14.5716

Can this interval be widened? Or does it look like I must modify my problem sets to stay within plus/minus 3.7 standard deviation?

Thanks for any feedback,

Tim

### Re: 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: