Week-8 Exercise on finding number of points outside n-dim sphere

Hi Team,
I installed Numpy(1.18.3) module on my Python 3.8.1.
When I run the below code-

import numpy as np
points= np.random.rand(npoints,ndim)
array([[4.31149161e-01, 9.82336015e-01],
[4.19884725e-04, 4.30463374e-01],
[8.29530220e-02, 6.08076230e-01]])

But as per the tutorial I should get random numbers between 0 to 1. I also tried the same code in Colab where i am getting right output as random numbers between 0 and 1.

So let me know is there any difference the numpy module of Python and Google Colab.


Hi @kavyakothari55
Though these numbers seem to be random, these are not totally random values, instead these are simulated ones which look like totally random.
There’s something called as random seed, which comes into use whenever we want these random looking numbers to be exactly same, every time we call that particular seed.
Maybe this is the reason you’re getting exact same numbers despute running your code on different machines, different environments.

So how to resolve it and get random numbers between 0 and 1.

the numbers are between 0 and 1 rite, i don’t seem to understand the confusion

1 Like

The numbers are between 0 and 1 but what I want is to display without exponents-
4.19884725e-04 -> 0.000419884725

Hi Kavya,

It is just a matter of how the computer stores it and displays it. It wont make any difference in the final answer.
You can use round() function to round off all results to n number of digits if you like. But i wouldn’t worry about it too much