Item -1 of a list

Wait, (num1 x 10) / (in x 10) should be the same as num1/in.

like this?

Same for the second input to random, and there's a similar "/ 10" and "x 10" undoing each other outside the PICK RANDOM block. C'mon, you don't need me to do arithmetic for you! :~P

ah, ok.

:white_check_mark: :~)

Here's a way to generate as many decimal places as memory and patience permits

image

It took a few seconds to generate 1 out of a google * google possible numbers between 0 and 1. I.e. 10,000 random digits.

The result is displayed as a fraction but it is a number between 0 and 1. [0, 1) since it will never generate 1.

Note also that it would be easy to change to use any other base - e.g. binary so it doubles and then adds either 0 or 1 each time.

I am mystified about the following

image

A problem with the Bignum library?

Here's the project (requires the bignum/rational library):

The project is

(without "Can" at the end, sorry about that)

And about this ?

Be wary of the limits of floating point numbers. I'm not sure how many zeros you used but note:

image

while

whatsapp script pic (2)

If you used too few zeros then it might report a number very slightly out of the range. Too many zeros and floating point arithmetic fails you.

See Number.EPSILON

@djdolphin (Probably because of hyperblocks?)

Funny how our fingers develop habits in a time of monopoly capitalism. :~)

I believe it's related to this Bignums/random need rounding

You caught me right when spring break started, so I'll fix the issue soon.

Oh, right, I forgot all about that thread.

You can't use Math.random() for random bignums, because floats only have 15½ significant digits. I guess the right thing is to generate them digit by digit, generating lots more digits than the user's desired range really needs and then scaling in exact integer arithmetic.

Random exact rationals may just be two random bignums as numerator and denominator, but I'm not sure, because common factors may make some results more frequent than others. Some mathematician will have to figure that out...

Random complex numbers can't be made with the PICK RANDOM block, because complex numbers aren't ordered, so the idea of specifying a range won't work. Instead the user will have to pick two random reals/bignums/rationals as desired and then turn them into a complex number.

Thanks!

Yes. I meant googol. Embarrassing...

So, here's Wikipedia on random numbers. It's about as readable as all the other Wikipedia math articles, but it does have one piece of good news:

GNU Scientific Library has a section entitled "Random Number Distributions" with routines for sampling under more than twenty different distributions.

The GNU documentation is often readable, or maybe you can just steal code from them, supposing it comes in arbitrary precision.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.