Jump to content



Photo
- - - - -

Random Numbers


  • Please log in to reply
14 replies to this topic

#1 genesis

genesis

    UCF BASIC Programming Runner Up

  • Super Member
  • PipPipPipPip
  • 281 posts
  • Location:Perth, Australia
  • Interests:Speaking German, computers, defending CFX calculators...

  • Calculators:
    CFX 9850 GB+

Posted 19 April 2004 - 05:54 AM

Here are a few questions about the calculator's pseudo-random number generator:

Has anyone ever got 0 or 1 from the Ran# function? Theoretically, which of these are possible?
Do you think some numbers never appear using the function?
Does anyone know how they are generated? Is it a list, a random number table or something else?
Do the numbers continue after each time you reset the calculator? Are they different on brand new calculators and how is this possible?

Before I go, is i positive or negative? For those who think it's neither, remember i=-i is not true.

#2 CrimsonCasio

CrimsonCasio

    UCF Ambassador

  • [Legends]
  • PipPipPipPipPipPipPipPipPipPip
  • 3579 posts
  • Gender:Male
  • Location:USA
  • Interests:Claculators, Stephen King, Video Games, Calculators, Programming, Calculators, Reading, Calculators... hmm, what else... Ah! Calculators!

  • Calculators:
    Algebra FX2.0, CFX 9850Ga+, Classpad 300

Posted 19 April 2004 - 06:45 AM

well, im not sure but remember that i is defined as sqrt(-1) so negative i is actually -1*sqrt(-1)

#3 Overlord

Overlord

    Casio Technician

  • Moderator
  • PipPipPipPipPipPip
  • 355 posts
  • Gender:Male
  • Location:Brussels - Belgium
  • Interests:Math Researcher

  • Calculators:
    My head - C300 OS 3.00 - G100 Rom 1.02 - G65 - G60 - G25

Posted 19 April 2004 - 07:21 AM

-random : strictly saying, you have a probability of 0 having a fixed number since there are an infinity number of reals between 0 and 1 :D... on the calc, you will never have 1 since it's [0, 1[ but i never got 0. if it's REALLY random (but it certainly isn't) As the 1 is excluded, you may admit that the calc takes the floor at 10^-15 (precision of the calc) of a random real number, so to have 0 the random number must be 0 <= number < 10^-15, so a probability of 0,0000000000001 % :P
i never had 0 without a 'Int'.

for the AFX, you have 2 modes generating random numbers, if you do Ran# X where X is an integer from 1 to 9, you get a random number from the random list #X (retry to have the next number), so if you do Ran# 1, Ran# 2, Ran# 1, Ran# 1, the first and the third will be same.
for the normal mode i don't know exactly

you'll never know about the new calcs as i suppose that the calcs are tested before selling, so they aren't really new ^^

- i is not positive and not negative, the complexes are neither positive neither negative, and there are no usual order relation like <=, >=

#4 genesis

genesis

    UCF BASIC Programming Runner Up

  • Super Member
  • PipPipPipPip
  • 281 posts
  • Location:Perth, Australia
  • Interests:Speaking German, computers, defending CFX calculators...

  • Calculators:
    CFX 9850 GB+

Posted 19 April 2004 - 10:38 AM

ARRGGHH!!! :profanity: Don't say 1 in infinity is 0!!! NEVER!!! Everyone keeps telling me 1 over infinity is 0 but it isn't! If there are infinite objects and one of them is the one you want, there is a chance of getting it because IT EXISTS!!!

I would have to agree that a random number x is as you said: 0<=x<1, just for the sake of the Int function (BTW, random numbers don't go further than the 10 digits on the screen).

#5 PerCasioAdAstra

PerCasioAdAstra

    Casio Addict

  • Members
  • PipPipPip
  • 83 posts
  • Location:Stavanger, Norway
  • Interests:Programming, gaming, gf, ..

  • Calculators:
    CFX 9850 GB PLUS WE;

Posted 19 April 2004 - 04:17 PM

during the testing of my game, where i used Ran# (CFX) function to determine the action of the "enemy" unit (i.e. is it a normal attack, is it a magic skill?), i encountered something weird about the Ran# function

1->M
Ran#->S
S>,5=>5->M

This code should give me an about 50-50 chance that the "enemy" would use either trick #1, or trick #5 (defined by the variable M).
The simple question is: why does the "enemy" use trick #1 about 90 % of the time, and the remaining percents on trick #5. I've runned it through a loop, and got an average of: M=1 => 85%, M=5 => 15%

And no, i didn't just run it 30 times, i made the calc do it for about 500 times before giving me the result.

(chapter two)
i changed the code from S>,5=>5->M to S<,5=>5-M
Now, the "enemy" does each of these tricks about 50 % of the time, as it "should".

Anyone familiar with this problem?

#6 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking &amp; Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool &amp; Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 19 April 2004 - 06:58 PM

personally, i think it is quite hard to define 'random number'. lets say you had a scale of 1 to 10 and picked nubers at random, you would either expect:

1) a fairly even spread of nmbers from 1 to 10
2) a random assortment, that is speard randomly, in other words NOT evenly!

as you can see just to define random is not easy

#7 PerCasioAdAstra

PerCasioAdAstra

    Casio Addict

  • Members
  • PipPipPip
  • 83 posts
  • Location:Stavanger, Norway
  • Interests:Programming, gaming, gf, ..

  • Calculators:
    CFX 9850 GB PLUS WE;

Posted 19 April 2004 - 07:24 PM

Your choice #2 there is a random spread of several random numbers. In other words, you're doing ran#*ran# :P

You're random (i think thats an expression) :P

#8 Andy.Davies

Andy.Davies

    Forum Ghost

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1547 posts
  • Gender:Male
  • Location:Dorset, England
  • Interests:Age: 18
    Studying: MEng in cybernetics at Reading uni
    Interests: Progaming (VB, VB.Net, C#, Casio Basic)
    Computers UBBD (Using, Building, Breaking &amp; Destroying)
    Gaming (FPS, RTS, RPG)
    Electronics
    Rock Music (Preferably Loud)
    Riley's (Pool &amp; Snooker Bar)
    Driving (Preferably fast)
    Aikedo (Martial Art)

  • Calculators:
    Algebra FX 2.0 ROM 1.01, FX9750G

Posted 19 April 2004 - 08:53 PM

lol it is an expression, and yes i am very random :lol2:

#9 CrimsonCasio

CrimsonCasio

    UCF Ambassador

  • [Legends]
  • PipPipPipPipPipPipPipPipPipPip
  • 3579 posts
  • Gender:Male
  • Location:USA
  • Interests:Claculators, Stephen King, Video Games, Calculators, Programming, Calculators, Reading, Calculators... hmm, what else... Ah! Calculators!

  • Calculators:
    Algebra FX2.0, CFX 9850Ga+, Classpad 300

Posted 19 April 2004 - 09:20 PM

heres a random number routine for the AFX that should be pretty dang random:

A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z+r+o
Abs(int(Ans))
(int(Ans))-(((int(Ans/10))*10)
int(((Ans/2)*2)+.5)
(int(Ans*Rand# Ans)/10)+(int(Ans*Rand# Ans)/100)+(int(Ans*Rand# Ans)/1000)+(int(Ans*Rand# Ans)/10000))

just run that and it will return a digit between 0 and 1 (note that it cannot return 1)

-------EDIT-------
slight math correction :)

english translation:
add all the variables in the calc
make them positive and cut off the decimal
get the first digit after the .
devide that number by 2, cut off the decimal, times it by 2, add .5, cut off the decimal
take random numbers from random lists use them to fill each place of the final number above, up to 5 below the decimal.

#10 PerCasioAdAstra

PerCasioAdAstra

    Casio Addict

  • Members
  • PipPipPip
  • 83 posts
  • Location:Stavanger, Norway
  • Interests:Programming, gaming, gf, ..

  • Calculators:
    CFX 9850 GB PLUS WE;

Posted 19 April 2004 - 09:32 PM

well.. that formulae looked just so sexy that i couldn't help trying to type it into my cfx, as it "seemed" to be compatible.

Well, i'm getting various numbers from about with values within [100,3000] --- :P

What about adding:

(Ans)^(-1) for the cfx? :D

#11 CrimsonCasio

CrimsonCasio

    UCF Ambassador

  • [Legends]
  • PipPipPipPipPipPipPipPipPipPip
  • 3579 posts
  • Gender:Male
  • Location:USA
  • Interests:Claculators, Stephen King, Video Games, Calculators, Programming, Calculators, Reading, Calculators... hmm, what else... Ah! Calculators!

  • Calculators:
    Algebra FX2.0, CFX 9850Ga+, Classpad 300

Posted 19 April 2004 - 10:49 PM

it wont work like intended on the CFX... try this slighly less random modification:
A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z+r+o
Abs(int(Ans))
(int(Ans))-(((int(Ans/10))*10)
int(((Ans/2)*2)+.5)
(int(Ans*Rand#)/10)+(int(Ans*Rand#)/100)+(int(Ans*Rand#)/1000)+(int(Ans*Rand#)/10000))

beware though, im doing this in my head so it might not produce the 0~1 results i think it does :)

oh, and btw: on the AFX all variables are allways inialized, on the CFX this could cause an error. you should initialize them all to random numbers at the start of the program (should you use this in an actuall program)

#12 huhn_m

huhn_m

    Casio Maniac

  • [Legends]
  • PipPipPipPipPipPipPipPip
  • 1957 posts
  • Gender:Male
  • Location:Germany / Dresden
  • Interests:Assembler(!!!)
    Computers and Programming
    Operating Systems
    Programmable Calculators
    Maths and everything arround it

  • Calculators:
    FX-82SX / AFX 2.0+ (ROM 1.03) / FX 1.0+ (ROM 1.03)

Posted 20 April 2004 - 04:52 AM

the ran# function does NEVER return 0 since the ran# function
is defined 0<x<1 so neither 0 NOR 1 will ever appear unlesyou use a rounding
function. (what would be useless since
you'd only get number 0 and 1 from it.

#13 BiTwhise

BiTwhise

    Casio Overgod

  • [Legends]
  • PipPipPipPipPipPipPip
  • 627 posts
  • Gender:Male
  • Location:Guildford, Surry, UK
  • Interests:Programming, games, consoles, martial arts

  • Calculators:
    FX9700WE, CFX9970G, AFX2.0, Classpad 300

Posted 20 April 2004 - 04:41 PM

ran is defined [0,1>
that's the most common way of defining a float rand anyway
as explained previosly, the chance of getting a particular number (like 0.0) is very low, and pseudo random number generators never cover their entire span before they repeat themselves

one of the programmatic reasons rand doesn't include 1 is, it's easier to generate a random bit pattern for a float if you know the exponent is static (this doesn't really yield true in the same way on the calculator since it uses BCD numbers).

obviously there are mathematical reasons you don't want the set to include 1, for instance that would make it very hard to generate numbers that span a certain range (if both 0 and 1 was included)

#14 Martin

Martin

    Casio Freak

  • Members
  • PipPipPipPip
  • 121 posts
  • Gender:Male
  • Location:Praha
  • Interests:asm on cfx9850

  • Calculators:
    fx82l
    fx7700GB
    cfx9850G
    TI92
    fx9860G SD
    Rheinmetall KEL IIc
    H. W. Ebmeyer - Tarema
    fx cg20

Posted 22 April 2004 - 01:40 PM

Has anyone ever got 0 or 1 from the Ran# function? Theoretically, which of these are possible?

I got once 0 from RAN# on my old good fx770GB , but this model computed Ran# for 3 digits only, so I got 0.000 . Once I got also 0.999 :-)
I have found in the manual, that Ran# returns numbers in 0..1; 0 included, 1 excluded

#15 Guest_Antonio_*

Guest_Antonio_*
  • Guests

Posted 05 December 2010 - 05:36 PM

The RAN function means the calculator return any three digit number between [0, 1) (include 0 but not 1) and the probability of any of them is the same. Theorically you can get 1000 diferent random numbers. I guess the calculator have a random number generator and take the seed from the batery, but I don´t know for sure.

I hope this help :nod:




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users