Software Design
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreSoftware Design

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old August 28th, 2003, 01:31 PM
don_sparko's Avatar
don_sparko don_sparko is offline
Digitally Challenged
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2003
Posts: 280 don_sparko User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 54 m 14 sec
Reputation Power: 6
Random Number Question

ok do you have a better chance of getting a repeat if you have an 8 digit random number or 2 concatinated 4 digit numbers? or 4 concatinated 2 digit numbers?
__________________
My brain cells are like a storm trooper's armor: useless

Reply With Quote
  #2  
Old August 31st, 2003, 09:56 AM
coolnfundu coolnfundu is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: India
Posts: 9 coolnfundu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 20 m 5 sec
Reputation Power: 0
Send a message via Yahoo to coolnfundu
humn

interesting question!

which algo r u using ?

i think it wud work better keeping it simple and choosing a better algorithm

if u r dead into doin concatenation then the results depend on the algorithm but shud not be of much siginificance in improvement

thats wats my opinion! will check it n let ya know!

till then keeping experimenting111111

Reply With Quote
  #3  
Old September 23rd, 2003, 11:35 AM
cono cono is offline
Coder.
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 12 cono User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It's a matter of statistics.


Probability = favorable cases / possible cases


For eight digits, the chance is P = 1 / 10^(8-1)
For 4 and 2 digits, you have to chain the events. For example, when u have 2 groups of 4 digits, not only the first group has to be a repeat, but also the 2nd one in order to be a full repeat.

Hope that helps.

Reply With Quote
  #4  
Old September 23rd, 2003, 07:02 PM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is online now
Banned ;)
Click here for more information.
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,720 Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level)Scorpions4ever User rank is General 3rd Grade (Above 100000 Reputation Level) 
Time spent in forums: 1 Month 3 Days 13 h 28 m 54 sec
Reputation Power: 1179
Hehe just saw this question. Assuming we have a good random number generator and assuming the restriction that the random number has to always be 8 digits long, we get some very interesting conclusions:

To make a random 8 digit number from four 2 digit numbers, we must ensure that each of the four numbers picked is 2 digits long (we're assuming no left padding a number with zeroes, if the number is only one digit long). For each two digit number, there are (99 - 10 + 1) possible combinations (i.e) max 2 digit number - min 2 digit number + 1 = 90 possible combinations. Hence, to make an 8 digit number from four two digit picks, we get 90 * 90 * 90 * 90 = 65,610,000 possibilities.

For a random 4 digit number under the same conditions, there are 9999 - 1000 + 1 = 9000 possibilities. Hence, concatenating two 4 digit numbers gives us 9000 * 9000 = 81,000,000 possibilities.

For a random 8 digit number, there are (99,999,999 - 10,000,000 + 1) = 90,000,000 possibilities.

Therefore, with our restrictions noted above, picking four 2 digit numbers gives us the best chance of repeating a number. Note that if you remove the restriction for numbers to always be eight digits long and/or remove the rule about not left padding single digit numbers with 0's, then there will be equal probabilities, i.e 1 in 10^8.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month

Reply With Quote
  #5  
Old September 26th, 2003, 04:20 AM
TGV TGV is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 TGV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
No difference if ...

Why shouldn't 4 or 2 digit numbers start with a 0? If they do, i.e. if you generate numbers between 0 and 9999 or 0 and 99, all probabilities are identical.

If you are interested in increasing the number of repetitions, you should follow another strategy.

The one suggested by the previous replier is to leave out digits (in his case, the digit 0 at the start of a number). E.g., if you only allow 1s in your "random" numbers, the number of repeats is quite high.

You could also write a biased generator that generates digit for digit and for every next digit first tests if it should be repetition of the previous one, and otherwise choose from the remaining 9.

Reply With Quote
  #6  
Old September 29th, 2003, 03:28 PM
JunkCookie JunkCookie is offline
Vote Libertarian
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Location: N'wallins
Posts: 277 JunkCookie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 36 m 27 sec
Reputation Power: 6
interesting question.

I assume we're really trying to minimize repeats.

Given that a RNG is designed to achieve a uniform distribution across its output window, I tend to think that it's easier to heuristically design a RNG algorithm that approaches the uniform distribution across the integers 0-9 rather than over a larger set, since there will be less potential holes.

If this is true, then a concatenation of 8 single-digit RN's would be more random (closer to a uniform distribution over the long haul) than an 8-digit RN.

Just a thought..
__________________
  • "Write programs as if the most important communication they do is not to the computer that executes them but to the human beings who will read and maintain the source code in the future" - ESR, The Art of UNIX Programming
  • "Programs must be written for people to read, and only incidentally for machines to execute." - Abelson & Sussman, SICP, preface to the first edition
  • "Programs must be written for machines to execute or else you just have a boring book" - DaWei_M
  • Vote Libertarian

Last edited by CokeJunkie : September 29th, 2003 at 06:23 PM.

Reply With Quote
  #7  
Old October 1st, 2003, 03:56 AM
TGV TGV is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 TGV User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
It ain't that bad...

There are good RNGs that can generate true 32 bit random values, so that would be sufficient to generate 8 digits. If you have a bad RNG, you wouldn't want to have it generate 8 digits in a row, since they are known to have rather strong relations between successive draws (e.g., the linear congruency method used in all standard C libraries for rand() always switches between odd and even on successive draws...).

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreSoftware Design > Random Number Question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT