Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
I have a new challenge
#11
nah, qb's random number generator is rubbish. I'll skip over the fact that you can't ever generate truely random numbers, but there are better techniques. Anyway, here's a piece of code I wrote that kinda matches the quality of QB's:

Seed dw ?
MulVal dw 7361h ; Some prime number

rand proc
mov ax, Seed
mov dx, MulVal
mul dx
inc ax
mov Seed, ax
ret
rand endp


So you can imagine why it's so crap..

As far as this challenge goes..umm..I think you're a wee bit inexerienced to be placing coherent challenges Smile
Reply
#12
I recall this observation about the QB RND function:

Quote:The function RND will produce a series of 16,777,206 random numbers and then repeat. These numbers are the only ones ever produced by RND.

Issuing the command RANDOMIZE TIMER will not change anything except the point in the series to start. This increases the surprise-factor however.
img]http://usuarios.vtr.net/~disaster/sigs/annoyizer.php[/img]
Reply
#13
Here's another one I am uncertain about:

Given a size A, find the largest B such that
2^(B-1) < A < 2^B.

So, find the ceiling of the log((base2) n) of a number as quickly as algorithmically possible.
Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
Reply
#14
Well the only way to get better random numbers is to do a "randomize timer" statement before you set any random variables. Microsoft's GORILLA.BAS shows a good randomize function that should be made standard in all progs with random variables:

Code:
FUNCTION ran (x, c)

RANDOMIZE TIMER

ran = INT(RND * x) + c

END FUNCTION

Anyone got any other ideas for randomizing variables?
Reply
#15
<digs notes out on random variables>

I cant find all my notes at the moment, but from memory random variables are generated from fairly simple algorithms using very large prime numbers. The main goals of a good random variable generator are to have a large cycle length and for each value to have statistical independance from the others (ie cant make predictions about the next number given the last few).

Of course no algorithmic generator can ever produce truely random numbers (because its based on a formula), but if the cycle length is long enough and statistical independance is achieved then it becomes difficult or impossible to tell that the sequence isnt random.

Quote:I'll skip over the fact that you can't ever generate truely random numbers

Thats not entirely true, it is accurate if you are refering to random numbers generated with computers which are usually formula based and use the timer to generate a seed value, however there have been studies done in using natural or real world phenomena to generate random numbers. I have seen work done with random numbers generated by using a digital camera and a lava-lamp, the pictures were assigned a unique number by combining the values of each pixel. The numbers generated will have a finite cycle length, but a lava-lamp doesn't obey any formula for its behaviour so theoritcally the numbers should be completely random. Other studies have done similar experiments with other objects as random number generators.
esus saves.... Passes to Moses, shoots, he scores!
Reply
#16
Other methods used by security agencies include using a computer to record and assign a value to sound based on static on radio frequencies, probably one of the most random things out there.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)