How can I generate a random number on my ti-84 without the rand function

1.2k Views Asked by At

Is there an equation that is possible where I enter a seed, and it will give me the number from the seed. I want it to give me the same results as the rand function would give with the seed as 0. I have a ti-84 calculator with the functionality of remainder() (i think that is used in random equations).

2

There are 2 best solutions below

0
On

Assuming you want to replicate the built-in PRNG, this tell you exactly what you TI-84 is doing.


Edit:

Well I kind of lied. They refer to L'Ecuyer's method which points to a paper. The paper describes how to combine multiple multiplicative linear congruential generators.

Yes, the remainder function you talk about is used. A linear congruential generator is something like

$$x_{n+1}=ax_n+c \mod m$$

where $a,c,m$ are chosen judiciously. Then if $c=0$ then we have a multiplicative linear congruential generator. The thing is that (both of) these are very easily broken meaning given a sequence you can easy find $a,c,m$ and even if you aren't using them for security, they contain a lot of patterns. But they are very fast, easy to understand, and easy to program. So L'Ecuyer's paper talks about a method where you can combine a bunch of them to get a much higher quality generator.

The trouble here is I couldn't find anywhere how many MLCGs are being used in TI-84 or what the parameters are. So if you want the same exact algorithm as in TI-84, you'll probably have to break it to figure out all the parameters which might take a bit of work or some good data mining on google. Maybe someone has done something on this already.

2
On

Flip the TI-84 twice. If it comes up screen side first followed by battery side second, then consider this a zero. If it comes up battery side followed by screen side, consider this a one. If it comes up screen-screen or batter-battery, then double toss again.

Eventually, you'll get random bit (see here). If you want a number in the range 1 - 1024, you are going to need to do at least 20 flips -- at least two flips per bit.

You are going to need to make sure you throw the TI-84 from a sufficient height to ensure that the tosses are random.