This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's TI-BASIC subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. TI-Basic => TI-BASIC
United-TI Archives -> TI-Basic
 
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Author Message
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 17 Apr 2004 02:45:25 pm    Post subject:

I was browsing through ticalc.org's BASIC archive (idn why) and found this program named "Aberration?".

Here's what the author claims:

Quote:
Is this supposed to happen[?]

The algorithm for the aberration function is as follows,

Lbl 1
Pt-On(1/rand,1/rand)
Pt-On(-1/rand,1/rand)
Pt-On(1/rand,-1/rand)
Pt-On(-1/rand,-1/rand)
Goto 1

If you look at the final display, you may notice that the points cluster around the origin [and the axes, I might add] .
However, because the coordinates are based on the rand function, shouldn't the points be distributed randomly, as in the 'Normal' function (identical in structure, but that the '1/' is absent).  What is it about the numerator of one that reduces the randomness of the 'rand'?  Or could it be that the 'rand' function isn't totally random? Write me if you have any ideas.



Here's what I wrote back to him:
Quote:
===========================================
Dear Wesley Cowan,


You've probably figured this out since you released the aberration program so long ago, but oh well, here it goes.

It's not an aberration at all!! The rand( function is indeed totally random, as you were able to notice with the "Normal" part, the one which did not include reciprocals. Here's your code:

      Lbl 1
      Pt-On(1/rand-1,1/rand-1)
      Pt-On(-1/rand+1,1/rand-1)
      Pt-On(1/rand-1,-1/rand+1)
      Pt-On(-1/rand+1,-1/rand+1)
      getKey->X
      If X=21 : Then
      Pause
      Goto M
      End

Sorry to say, but here's what you might want to do:

      While 1
      Pt-On(1/rand-1,1/rand-1)
      Pt-On(-1/rand+1,1/rand-1)
      Pt-On(1/rand-1,-1/rand+1)
      Pt-On(-1/rand+1,-1/rand+1)
      getKey->X
      If X=21 : Then
      Pause
      Goto M
      End
      End

A good rule of thumb is never to use labels... anywhere. They slow down the program by a lot!

What is actually hapenning is that when you get a random number (say the calculator gave you .7980701009), you divide that number by one (which gives you 1.253022759) then add a one (that is 2.253022759). When you do the same for the Y-axis, you get that coordinate for either the X-axis or the Y-axis.

You see, the calculator choose a random number for each digit of the rand function, which means that there's a 1 out of 10 chance for you to get a .0xxxxxxxx and even small chance for you to get a .00xxxxxx. So that means the your because you are dividing 1 by the number, you are more likely to get a number closer to zero. Now, it's already difficult to get a small number in the X-axis but to get another small number for the Y-axis is even tougher.

So you see, it's not the calculator's fault! All random functions (rand, randInt, randM, etc...)

TTYL and have fun programming,
Joe Pena


Anyone got any other ideas?

Screenshot!

(VTI - no speed restrictions)


Last edited by Guest on 09 Nov 2004 10:22:06 am; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 17 Apr 2004 04:14:22 pm    Post subject:

I hate these people! They stole my "electron" program I wrote years ago!
Of course, mine was superior. It went

Repeat getKey
rand^-1->R
2[font="symbol"]p
rand
Pt-On(Rsin(Ans),Rcos(Ans
End

and drew them in circles, not an axes-bound thing.
Back to top
DigiTan
Unregistered HyperCam 2


Super Elite (Last Title)


Joined: 10 Nov 2003
Posts: 4468

Posted: 17 Apr 2004 06:16:21 pm    Post subject:

I tried a similar prog with a wandering "particle" that always appeared to loiter around the (0,0) area. You should try publishing this at ticalc, brazucs16--this is a very useful finding. Also, does anyone know of any texts that explain exactly how the rand functions work?
Back to top
Ray Kremer


Member


Joined: 16 Feb 2004
Posts: 237

Posted: 17 Apr 2004 08:47:05 pm    Post subject:

DigiTan wrote:
Also, does anyone know of any texts that explain exactly how the rand functions work?

http://www.angelfire.com/realm/ti_tiplist/...ist/tip6_37.pdf

That's for the 89/92, but I'm fairly sure the 8x calculators use the same thing for their rand functions.

Quote:
You see, the calculator choose a random number for each digit of the rand function

I don't think that's it.

Let's give this a real world test. Rand gives numbers between 0 and 1. Let's pretend we did rand ten times and got numbers close to these:
.1, .2, .3, .4, .5, .6, .7, .8, .9, 1

The negatives that the program uses to throw the points out into the other quadrants are fairly pointless, if we're just testing the spread of random numbers we want to keep them all in the same place anyway. Now, the problem with taking the reciprocal:
10, 5, 3.33, 2.5, 2, 1.67, 1.43, 1.25, 1.11, 1

Oh look, our ten evenly distributed numbers are now not evenly distrbuted. Your replacement code probably isn't any better, since it still involves the reciprocal.

The real way to do this is to set up bins, say 0 to .05, .05 to .10, and so on. Run rand a bunch of times, and add one to the appropriate bin for each one. Then compare the values of all the bins, maybe plot them with the stat functions. The values should all be about the same.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 18 Apr 2004 09:33:05 am    Post subject:

DigiTan wrote:
I tried a similar prog with a wandering "particle" that always appeared to loiter around the (0,0) area.  You should try publishing this at ticalc, brazucs16--this is a very useful finding.

I disagree.

1. Ticalc is stuck with enough junk.

2. It's a very useful finding that happened to be very usefully found around 400 years ago.

3. He found it in someone else's program already at ticalc.
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 19 Apr 2004 12:15:16 am    Post subject:

Sir Robin wrote:
DigiTan wrote:
I tried a similar prog with a wandering "particle" that always appeared to loiter around the (0,0) area.  You should try publishing this at ticalc, brazucs16--this is a very useful finding.

I disagree.

1. Ticalc is stuck with enough junk.

2. It's a very useful finding that happened to be very usefully found around 400 years ago.

3. He found it in someone else's program already at ticalc.

yeah, I already wrote to the guy. I think that should be enough. Besides, I'd rather post it in forums people actually go to, nobody cares about ticalc.org's forums (even though I'm probably gonna get about 50 replies of people who do). That's why there's UTI.


Last edited by Guest on 09 Nov 2004 10:23:35 am; edited 1 time in total
Back to top
Darth Android
DragonOS Dev Team


Bandwidth Hog


Joined: 31 May 2003
Posts: 2104

Posted: 20 Apr 2004 02:25:42 am    Post subject:

brazucs16 wrote:
The rand( function is indeed totally random,

i have some holes to shoot in your logic
*pulls out shotgun*
if we define "random" as unable to be successfully predicted consistanly, then at this point in time, is it impossible for a computer of any kind to generate random numbers. instead, they produce pseudo-random numbers (pseudo means fake, for those of you to lazy to look it up in a dictionary) and can accuratly be predicted.
for example, type 1->rand
then type randInt(1,10 (we use randInt( instead of rand for simplicity purposes) and hit enter a few times.
the numbers will be (with a 83+, that is at least) 8,9,3,5,7,1,1,7,2,3,8,10,2,4... every single time you repeat these steps.
what im getting at is that due to our computer illiterate society, meaning have been meshed. people say that computers generate random numbers, and on small test, they seemingly do. but on larger tests (took the program 2 hours to finish), i find that that always lean one way or another (my 83+ leans to the upper end of the numbers). so, i let it slide, most of the time when ppl say "random". but, i just wanted to point out that when you say "totaly random", that is not the case.

i dont know maybe im taking this way out of preportions, maybe im not. i know im getting tired of ppl saying stuff thats isnt true.

oh, and Brazucs, dont double post. there is a little button above every one of your posts that says "edit". please use it.


Last edited by Guest on 20 Apr 2004 02:26:56 am; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 20 Apr 2004 07:31:43 am    Post subject:

Quote:
if we define "random" as unable to be successfully predicted consistanly, then at this point in time, is it impossible for a computer of any kind to generate random numbers. instead, they produce pseudo-random numbers (pseudo means fake, for those of you to lazy to look it up in a dictionary) and can accuratly be predicted.
Actually, you could base it on the temperatures of your CPU or harddisk making it quite random indeed.

Quote:
oh, and Brazucs, dont double post. there is a little button above every one of your posts that says "edit". please use it.
As you (being a mod) can see he has already been warned.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 20 Apr 2004 04:33:06 pm    Post subject:

Quote:
Quote:
You see, the calculator choose a random number for each digit of the rand function
I don't think that's it.

The end result is the same.

Also, the numbers are for all purposes random since there is no difference under normal conditions between using rand and truly random numbers.
Quote:
then type randInt(1,10 (we use randInt( instead of rand for simplicity purposes) and hit enter a few times.
the numbers will be (with a 83+, that is at least) 8,9,3,5,7,1,1,7,2,3,8,10,2,4... every single time you repeat these steps.

Also on other TI calculators because the same steps are used.
Back to top
Brazucs
I have no idea what my avatar is.


Super Elite (Last Title)


Joined: 31 Mar 2004
Posts: 3349

Posted: 20 Apr 2004 05:05:31 pm    Post subject:

sorry for the double-posting guys.. Neutral I didn't know you couldn't...

meh.... wth, I'll send it to ticalc.org Razz


Last edited by Guest on 20 Apr 2004 05:17:42 pm; edited 1 time in total
Back to top
62 52 53 53
Formerly known as 62 52 53 53


Active Member


Joined: 30 May 2003
Posts: 607

Posted: 22 Apr 2004 04:10:36 pm    Post subject:

the temperature of your cpu is not random. Given enough data, I could predict it perfectly, and the next number of the sequence.
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 22 Apr 2004 04:13:46 pm    Post subject:

Same deal,
Me wrote:
Also, the numbers are for all purposes random since there is no difference under normal conditions between using rand and truly random numbers.
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 01 May 2004 04:10:06 pm    Post subject:

62 52 53 53 wrote:
the temperature of your cpu is not random. Given enough data, I could predict it perfectly, and the next number of the sequence.

And it would most likely be grouped around some value, with only a few scattered higher or lower values. You would probably get a curve close to normal instead of the evenly distributed graph that indicates true randomness after enough trials.

Spyderbyte
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 01 May 2004 04:16:44 pm    Post subject:

Measure it with greater presision and only use the digits after the period.
Back to top
Notepad_Gamer


Newbie


Joined: 29 Jan 2004
Posts: 36

Posted: 01 May 2004 08:26:21 pm    Post subject:

I wonder if we can crack TI's random # code... Heres something i found. rand -> rand will put one number out, then the next time, it will always bring you to the number .9435974025. Secondly, randint(1,10) -> rand will always do 10,5,8,10,5,8,10...

Or we could take it the easy way by using VTI. Laughing
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 02 May 2004 12:03:25 pm    Post subject:

Well, the TI-89 generates the same random numbers, and it has two system variables for it, seed1 and seed2.
Some things I've found:
when both seed1 and seed2 are zero, rand() will be zero and seed1 and seed2 become the same number.
When you do rand() repeatedly, seed1 will alternate between 0 and that number, while seed2 will change unpredictably.

Edit: when seed2 = 1/seed1, it will become that same number as it becomes after they are both 0.


Last edited by Guest on 02 May 2004 12:07:21 pm; edited 1 time in total
Back to top
Ray Kremer


Member


Joined: 16 Feb 2004
Posts: 237

Posted: 02 May 2004 11:50:11 pm    Post subject:

Crack the random number code? Why? TI's already told us where they got the algorithm from.
Back to top
Smasher
I'm a llama!


Newbie


Joined: 25 May 2003
Posts: 15

Posted: 15 May 2004 06:27:06 pm    Post subject:

Sorry to bring up an old topic, but I think this merits further consideration:

Darth Android wrote:
but on larger tests (took the program 2 hours to finish), i find that that always lean one way or another (my 83+ leans to the upper end of the numbers). so, i let it slide, most of the time when ppl say "random". but, i just wanted to point out that when you say "totaly random", that is not the case.

I'm surprised by the results of your test. I just did a similar test myself, and I found no pattern whatsoever. I took 10,000 numbers (granted, smaller than your two hour test, but it should still be statistically valid), and took a statplot of the results. The numbers seemed to be totally random. When I did a linear regression on them, my slope was -9*10^-4 (-.0009), and my r^2 was 8.8 * 10^-6, or essentially 0. I'm wondering if perhaps there was a bug in your code that skewed the test results. Here's my source code, so you can find any flaws in my code/methodology:


Code:
:ClrHome
:0->dim(L1
:100->dim(L1
:For(M,1,100
:For(N,1,100
:int(100rand+1
:1+L1(Ans->L1(ans
:End
:Disp M // so I can see how far it's gotten
:End


The way my program works is to multiply every rand by 100 then add 1, take the integer portion of that, then increment the appropriate counter (so .00xx goes into L1(1, and .99xx goes into L1(100. It's my understanding that rand will never return 1.0000..., but even if this is false the chances of this happening are small enough that they'll have no actual effect on the results. Just to be on the safe side I'm starting a test with 100,000 numbers, using the same code as above except with N going to 1000.

Just to avoid confusion, I'm not trying to state that random numbers generated by a machine are truly random... I know they're not. I'm just saying that they should be random enough that any statistically significant sample size should yield an equal distribution.


Last edited by Guest on 15 May 2004 06:28:14 pm; edited 1 time in total
Back to top
DarkerLine
ceci n'est pas une |


Super Elite (Last Title)


Joined: 04 Nov 2003
Posts: 8328

Posted: 15 May 2004 07:01:05 pm    Post subject:

rand can return 1. And I don't see how the slope's being 0.0009 says anything about whether the numbers tend to be closer to 1 or 0. Now, if you average the rand's and get .5, then that will be more conclusive.
Back to top
X1011
10100111001


Active Member


Joined: 14 Nov 2003
Posts: 657

Posted: 16 May 2004 11:07:12 am    Post subject:


Code:
0
For(X,1,10000
Ans+rand
End
Ans


I got 5022.875... which is only 0.458% off of what would be expected.


Last edited by Guest on 16 May 2004 11:08:08 am; edited 1 time in total
Back to top
Display posts from previous:   
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
    » Goto page 1, 2  Next
» View previous topic :: View next topic  
Page 1 of 2 » All times are UTC - 5 Hours

 

Advertisement