Reputation: 11
I have tried running np.random.normal(1.75,0.20,1000)
multiple times and it always returns only positive values in the array.
Why does it always returns only positive values? Isn't supposed to contain some negative values too?
Upvotes: 0
Views: 811
Reputation: 492
In order to see a negative number, with a mean
of 1.75
and a sigma
of 0.20
, you should see a number which is at least 8.75
sigma
away from the mean.
The probability to see a number 7
sigma
away (in both directions) from the mean
is 1 in 390682215445
.
And the probability for 8.75
sigma
is even less.
You are making only 1000
tries.
For probabilities: see here
Upvotes: 3
Reputation: 27588
Negatives are very unlikely with that, they're just too far away. When I round to one digit, even for a million (rather than your 1000) values l get a distribution like this:
0.8 4
0.9 32
1.0 208
1.1 1099
1.2 4991
1.3 16614
1.4 43976
1.5 92127
1.6 149513
1.7 191929
1.8 191118
1.9 150418
2.0 91883
2.1 43602
2.2 16344
2.3 4777
2.4 1142
2.5 186
2.6 35
2.7 2
Code (Try it online!):
import numpy as np
from collections import Counter
a = np.random.normal(1.75,0.20,1000000)
ctr = Counter(round(x, 1) for x in a)
for x, count in sorted(ctr.items()):
print(x, count)
Upvotes: 0
Reputation: 493
The standard deviation you have inserted is such that most (99.7%) of the numbers that will be drawn will be greater than (1.75 - 3*0.20) = 1.15 and smaller than (1.75 + 3*0.20) = 2.35.
Look up this empirical rule:
Put simply: 99.7% of the values lie within 3 standard deviation from the mean.
Upvotes: 1