[Tutor] Need help to generate random number without library functions.
Mats Wichmann
mats at wichmann.us
Tue Sep 8 08:59:32 EDT 2020
On 9/7/20 1:39 PM, ROHAN RASKAR wrote:
> Dear Sir/Ma'am,
> I'm a student and beginner for learning python
> language. I want to generate 1000 random numbers which are normally
> distributed with mean 0.6 and 0.2 standard deviations. I tried a lot but I
> am getting some errors in code. Could you guide me? Thank you so much.
We don't know what motivates your question. If there's an assignment to
generate random numbers without using an existing library, then so be
it, that's what you need to do.
But...
There are some things that are quite hard in computing. Randomness is
one. Security is another. These are places where an excellent lesson to
learn is to leave those hard bits to mature code and not remake the same
mistakes those authors presumably did. Use the Python random module -
there's a ton of work in it, and it's pretty good now. For more
sophisticated stuff, there's scipy's stats module:
https://docs.scipy.org/doc/scipy/reference/stats.html
More information about the Tutor
mailing list