-1
$\begingroup$

I would like an algorithm which can generate a list of random, uniformly distributed floating point numbers from a given seed, ideally also being able to specify the number of decimal places.

The use case if for randomly generating datasets for education, so does not need to be secure. What would a good algorithm be for this? Ideally one that is easy to understand and easy to write in a programming language.

$\endgroup$
  • $\begingroup$ Well, many programming languages and programs include a function like "random()", which returns a floating point between 0 and 1 ... Could you use one of such? Which program are you using? $\endgroup$ – Matti P. Aug 4 '20 at 11:00
  • $\begingroup$ I'm using JavaScript which has Math.random(), but does not take a seed. Plus I would like to write the algorithm my self, to help me learn. $\endgroup$ – Max888 Aug 4 '20 at 11:08
  • 2
    $\begingroup$ On that case, I think that's more of a JavaScript/programming question, than a mathematics question. $\endgroup$ – Matti P. Aug 4 '20 at 11:09
  • $\begingroup$ @MattiP. I don't see how? Like I said, I want to code it up myself, so the language is mostly irrelevant. I just want to know what a sensible algorithm to use is, as many are complex because their priority is security, but for my purpose I don't need security. $\endgroup$ – Max888 Aug 4 '20 at 11:19
  • $\begingroup$ See Numerical Recipes. $\endgroup$ – Felix Marin Aug 5 '20 at 17:07
1
$\begingroup$

Use a LCG https://en.wikipedia.org/wiki/Linear_congruential_generator to generate a uniform integer and rescale it as you wish.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.