Login [Register]
Don't have an account? Register now to chat, post, use our tools, and much more.
As an intellectual exercise, I'm trying to figure out how to write a reasonably good RNG in TI-BASIC.

A while ago I made a Conway's Game of Life program with a random-ish board generator (which, by the way, turned out to be faster than rand). The basis of the algorithm, where A is the random number:


Code:
fPart(10^(A+7->A


Starting with a seed, maybe A=0.1. I don't see any pattern or relationship between successive numbers when graphing results, but the period should be no more than a few thousand.

* Is this method of pseudorandom number generation obviously flawed in another way?

* How can I test the quality of pseudorandom numbers generated (on-calc or otherwise)? Should I just implement some of the tests I've seen online?

* I just thought of using several of these, all seeded differently, and adding them modulo 1:


Code:
fPart(10^(L1+7->L1
fPart(sum(L1->A


Where L1 is seeded to a list of, say, 10 different numbers.

Does this improve the quality? My reasoning is that the different seeds probably have different periods, and therefore the overall period, which is the lcm of all of them, will be at least in the millions.
Your distribution is definitely skewed. Here are histograms of the first 200, and 2000 samples, seed with 0.1. Both show the same trend.


elfprince13: Using the following Matlab code


Code:
dim = 2000;

x = zeros(1,dim);
x(1) = 0.1;
for i=1:dim-1
    a = 10^(7 + x(i));
    x(i+1) = a - fix(a);
end
histogram(x,10)


I'm getting a somewhat flat distribution. I'm not sure if it's within the range of randomness or not.


When I change the dimension to 10000, the distribution flattens out more.
Quote:
I'm getting a somewhat flat distribution. I'm not sure if it's within the range of randomness or not.


Shouldn't you compare it to a proven psudorandom number generator? To see if it's within the range of randomness?

EDIT:
Maybe you could repeat it a random number of times?


Code:
int(rand*(10^(randInt(1,2->I
While I≠0
//random number generator goes here
I-1->I
End


EDIT #2

Marvel and feast your eyes on the fastest random # gen EVER XD

EDIT #3

It uses rand... DOH!
_iPhoenix_ wrote:

Shouldn't you compare it to a proven pseudorandom number generator? To see if it's within the range of randomness?


No, you should do a chi-squared test! See the Stats>Test menu on your TI calculator.
OldMathTeacher wrote:
_iPhoenix_ wrote:

Shouldn't you compare it to a proven pseudorandom number generator? To see if it's within the range of randomness?


No, you should do a chi-squared test! See the Stats>Test menu on your TI calculator.


A chi-squared test seems inappropriate for this situation.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are GMT - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement