« Prev  Page 1  Page 2  Page 3  Next » 
My two dice must be loaded! I get seven way more often than any other number :o

So in order to increase the randomness of a number, we independently randomize each digit of a 1100 digit, decimal, 1100 digit number?
I'd hate to see them come up with a number between 1 and 10 with this strategy. Especially since every number they obtain is going to be anywhere from 0 to 10^100. 
Random() returns increasingly randomer numbers the more you call it.

awful.....just plain awful...

If I multiply a random by a random and then build a random string with it, then that must make it more random! What a revelation!

Re: Random Stupidity
20080310 10:20
•
by
Gabriel Kiss
(unregistered)

yes it more random because you get a RANDOM^2 number!!!11oneeleven... and so on :) 
Well, since the range is so huge, I would have thought that just taking the result modulo ten should give a sufficiently even distribution; it's not like taking a 7bit random from 0127 modulo ten where each of the numbers 07 get 'one extra chance' to be picked than the others. However looking at their code, I can only assume they'd generate a random number between 1 and 10 by calling the random routine and repeatedly looping until they got one that fell in range..... ... that could take a little while. 
Re: Random Stupidity
20080310 10:29
•
by
Some Computer Scientist
(unregistered)

Knuth devoted an entire section talking about random methods for generating random numbers. It boiled down to this: DON'T
Random numbers are serious business. In cryptography, a secure random number generator can mean the difference between impossible to crack and trivial to break. This code is just an EPIC FAIL in every way. 
I know I can get even more randomer.
Let rand return a number between 2 and 9. Multiply by 9. Add the digits of the result together. Subtract 5. This should be as random as I need to get and as everyone knows, a formula is better than just calling rand(). 
The obvious solution would have been to set the random seed to a random value a random number of times before using Math.random to make it more randomer

Re: Random Stupidity
20080310 10:33
•
by
TraumaPony
(unregistered)

Actually, depending on the algorithm, the more times you call it, the more predictable it becomes. 
To quote Knuth:
"Random numbers should not be generated with a method chosen at random." 
Well I suppose they could do answer % 10 + 1, but I'm sure they have a much more convoluted function that does the same thing. 
the more i read this sentence, the less "random" looks like a proper word.. 
private int getRandomOverflowException() {
return (int) ((Math.random() * 100) * Math.random()); } 
Wonder what they're doing that needs superextraultra random numbers?

just remember. random * random = ultrarandom

Re: Random Stupidity
20080310 11:11
•
by
RobIII
(unregistered)

You have *GOT* to be kidding me! Where's your sarcasm detector? DUDE... 
Prime numbers are too predictable... Let's make sure we get less of those.

Re: Random Stupidity
20080310 11:12
•
by
Geezer coder
(unregistered)

"Wonder what they're doing that needs superextraultra random numbers? " They are getting paid by the line of code developed. 
with apologies to xkcd. 
I get that impression with a lot of the WTFs presented here.

Why not just return '1' every time?
After all, it's theoretically possible that your perfectlyrandom die rolls repeated 1's. And your callers wouldn't know any different, unless they kept a history (which most don't) ;) 
Still use Dilberts Random Number Generator:
Nine, Nine, Nine, Nine, Nine, Nine, Nine, Nine. 
I like to sort my random numbers.

Re: Random Stupidity
20080310 11:53
•
by
Nerf Herder
(unregistered)

OMGZ that totally equals my birthday! It really DOES work! Now forward this to 20 friends or u'll have bad luck. LOLZ. 
Irish she were drunk too. Rowr. There, fixed that for ya. 
perhaps it was written by a random code generator

actachally, taking n sequential samples from a random number generator, you may end up with a lessrandom number.

A little bit of knowledge is a dangerous thing.

they should call those guys HD Random Numbers...for "High Degree" of Randomness. The degree increases as you multiply by more random numbers!

Apostrophe's and they're use's.

Re: Random Stupidity
20080310 12:26
•
by
Richard
(unregistered)

int getRandomNumber()
{ int ret; printf("Please throw the dice that you will find under your chair and enter the result"); scanf("%d",&ret); return ret; } 
/** 
So, there is a 1 in 100 chance that the value left of the '.' is 0, and there is a 1 in 100 chance that the value left of the '.' will range between 1*10^100 to 9.999...*10^10 ?
Does true randomness typically lean towards smaller values? 

I particularly like it how standard generators are not good enough for this "programmer" (despite using them...), but it's OK to have getRandomDigit() heavily biased against returning '9' :)

The most random thing about the code is that it's nicely obfuscated. But I think this is what's going on  forgive me for being obvious, but I really want to know what it does so I never, EVER do it myself.
* getRandomDigit does a pretty reliable job of returning one of the ten strings '0' through '9'... I think. * getRandomNumberOfDigits generates a number between 0 and 100, then multiplies it by a number between 0 and 1, generating a significantly less random number between 0 and 100. It converts it to an integer, so the number will probably be between 0 and 99. Converting to integer already does a pretty good job of derandomizing the number, so the multiplication really just wastes clock cycles. * getRandomDigitString calls getRandomNumberOfDigits to see how many numbers should be in the string. However, getRandomNumberOfDigits could return zero. So it discards 1% of its randomness and equates "zero digits" to "one digit", with that digit being "0". Maybe it only eliminated 0.1% of the randomness. * Finally, take a nearlyrandom string of 199 numbers (with a greater than 1% chance that the string is "0"), add a decimal, add another nearlyrandom string of 199 numbers (again, good odds that the string is "0"), and cram it into a Double. This is about as good a WTF as you can get. The function works without error, doing exactly what it was programmed to do, but the world would be a better place if it would just throw a "YOU CAN'T BE SERIOUS" error and die. 
fprintf(stderr, "DICE_NOT_FOUND"); 
I think a name change for the site is in order. I suggest the Daily What In Tarnation (WIT). Maybe if "wit" were explicitly in the title people would be more inclined to recognize it.
Captcha: caecus 
Re: Random Stupidity
20080310 13:11
•
by
Maybe Anon
(unregistered)

It's also final so that people can't subclass it and change his logic...
This is a ordered version of 20 runs, note how it goes from very very small, to very very big, very very quickly. Very very. The numbers look about the same with thousands of runs, very small then very big. I saw a few plain "0"s too.

Re: Random Stupidity
20080310 13:37
•
by
sweavo
(unregistered)

There ya go, very small and very big. How random do you want?
It's interesting to note though, that not only do the numbers themselves vary, but so does their randomness. 
I asked my brian to plot a distribution curve of this, and it asplode.
Assuming math.random is evenly distributed between 0.0 <= x < 1.0 then number of digits is going to peak around 25 in't it? so then your distribution of actual values is some freaky integral of an exponential. 
Hi there  OP here. I can't believe nobody mentioned that no routine that depends upon a random number generator can ever really be any more random than the underlying generator being used. In other words, assuming that the routine is implemented perfectly (as many have pointed out, it's not), it can never be any more random than: Math.random() 
Re: Random Stupidity
20080310 13:46
•
by
Derek
(unregistered)

that always equals 4. Why not just use xkcd's version, it's less wordy, but has the same result. 
Hey, I DID that. Didn't know random number existed, was using pascal, was years ago, one of my very first programs. You feel ashame when you discover there exist a random() function :/ At least it wasn't professional :D 
Re: Random Stupidity
20080310 13:49
•
by
Nerf Herder
(unregistered)

I think it was sarcastic. 
This is what I would do:
int counter = 1; public int getRandomInt() { counter++; switch (counter) { case 0: return 4; case 1: return 2; case 2: return 5; case 3: return 4; //and so on default: //this can't happen anyway.... throw new SomeException(); } } You just need to do a proper sizing on project start and some cheap labor to roll dice. You could even sell updates to your software supplying new randomness! 
« Prev  Page 1  Page 2  Page 3  Next » 