Click here to Skip to main content
15,886,639 members
Home / Discussions / Algorithms
   

Algorithms

 
AnswerRe: matlab a function in m-file Pin
rbuchana31-Mar-07 9:48
rbuchana31-Mar-07 9:48 
AnswerRe: matlab a function in m-file Pin
Sean Cundiff31-Mar-07 13:24
Sean Cundiff31-Mar-07 13:24 
Questionbandwidth question Pin
Planker29-Mar-07 19:08
Planker29-Mar-07 19:08 
AnswerRe: bandwidth question Pin
Rilhas19-May-07 10:03
Rilhas19-May-07 10:03 
Questiongenerate unrepeated serials Pin
samira forooghi28-Mar-07 20:05
samira forooghi28-Mar-07 20:05 
AnswerRe: generate unrepeated serials Pin
Nathan Addy29-Mar-07 15:19
Nathan Addy29-Mar-07 15:19 
AnswerRe: generate unrepeated serials Pin
Tim Paaschen29-Mar-07 20:18
Tim Paaschen29-Mar-07 20:18 
GeneralRe: generate unrepeated serials Pin
Nathan Addy30-Mar-07 7:38
Nathan Addy30-Mar-07 7:38 
Actually, if I understand your algorithm correctly, I don't think it's the best thing to do. (Please correct me if I'm wrong though)

Basically, your set of numbers will be much less random than they should be (they will end up being much more evenly spread over the range than they would be if they were "really" random).

If you try to generate a list of a bunch of random and non-equal 4 digit numbers, the way I understand your algorithm works, it would do something like the following (got the random umbers on the right hand side from python).

10 . 47 = 1047
11 . 67 = 1167
12 . 77 = 1277
13 . 23 = 1323
14 . 01 = 1411

And you're saying that because of the numbers on the left, from 10 to 14, guarantee the numbers will be unique (which is true), and the ones on the right "randomize" the numbers. The problem is that your numbers aren't very random at all (not uniformly distributed in the range 1000-9999). If you generate 40 numbers this way, none of them will be over 5000. For a really random set of 40 different numbers, the chance would be somewhere around (but not equal to, because the numbers are all different) about (1/2)^40, which is no chance at all.

If you switch your algorithm around, by putting the random half first, you get something MUCH better. In this case, you would get the numbers 4710, 6711, 7712, 2313, 1114. Your numbers will be much, much, much more random. In this guys case, you'd generate 11 digit random numbers, and use the last 5 for the sequence. They still won't be as great as they could theoretically be. If, for example, you did statistical tests of these numbers, you would find that exactly 10% of the numbers end in 1, 10% in 2, and so on. Obviously that wouldn't be true of a "really" random set.

Basically the best way to do it is just generate random numbers in that range. There is about a one in 50 million chance you'll have overlaps if your random number generator is good.
GeneralRe: generate unrepeated serials Pin
Tim Paaschen1-Apr-07 20:40
Tim Paaschen1-Apr-07 20:40 
GeneralRe: generate unrepeated serials [modified] Pin
cp98761-Apr-07 21:13
cp98761-Apr-07 21:13 
GeneralRe: generate unrepeated serials Pin
Nathan Addy2-Apr-07 8:58
Nathan Addy2-Apr-07 8:58 
GeneralRe: generate unrepeated serials Pin
cp98762-Apr-07 15:38
cp98762-Apr-07 15:38 
Questionhelp me Pin
phowarso28-Mar-07 4:38
phowarso28-Mar-07 4:38 
AnswerRe: help me Pin
Newbie0028-Mar-07 5:34
Newbie0028-Mar-07 5:34 
GeneralRe: help me Pin
phowarso28-Mar-07 5:56
phowarso28-Mar-07 5:56 
GeneralRe: help me Pin
phowarso28-Mar-07 5:56
phowarso28-Mar-07 5:56 
AnswerRe: help me Pin
cp987628-Mar-07 17:19
cp987628-Mar-07 17:19 
QuestionChess genetic algorithm Pin
blashey25-Mar-07 4:01
blashey25-Mar-07 4:01 
AnswerRe: Chess genetic algorithm Pin
Paul Conrad14-Jul-07 10:20
professionalPaul Conrad14-Jul-07 10:20 
QuestionRough Set Algorithm Pin
kkadir24-Mar-07 14:05
kkadir24-Mar-07 14:05 
AnswerRe: Rough Set Algorithm Pin
Paul Conrad21-Jul-07 18:06
professionalPaul Conrad21-Jul-07 18:06 
QuestionCube and Rectangle Intersection Pin
jk chan23-Mar-07 3:03
jk chan23-Mar-07 3:03 
AnswerRe: Cube and Rectangle Intersection Pin
Dan Neely23-Mar-07 3:20
Dan Neely23-Mar-07 3:20 
QuestionMath research team maps E8! Pin
73Zeppelin19-Mar-07 20:09
73Zeppelin19-Mar-07 20:09 
AnswerRe: Math research team maps E8! Pin
Maximilien20-Mar-07 3:17
Maximilien20-Mar-07 3:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.