Click here to Skip to main content
15,913,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: VC++ 6.0 interface question Pin
Rage11-Jul-02 22:12
professionalRage11-Jul-02 22:12 
GeneralRe: System Busy... Pin
Brad Bruce11-Jul-02 10:04
Brad Bruce11-Jul-02 10:04 
Generaldoble to String... Pin
Speedy11-Jul-02 9:37
Speedy11-Jul-02 9:37 
GeneralRe: doble to String... Pin
Joaquín M López Muñoz11-Jul-02 9:44
Joaquín M López Muñoz11-Jul-02 9:44 
Generalrandom NUmbers Pin
ib04212911-Jul-02 9:37
ib04212911-Jul-02 9:37 
GeneralRe: random NUmbers Pin
Joaquín M López Muñoz11-Jul-02 9:53
Joaquín M López Muñoz11-Jul-02 9:53 
GeneralRe: random NUmbers Pin
ib04212911-Jul-02 10:07
ib04212911-Jul-02 10:07 
GeneralRe: random NUmbers Pin
Joaquín M López Muñoz11-Jul-02 11:09
Joaquín M López Muñoz11-Jul-02 11:09 
Well there's a deficiency due to truncation problems, I guess you should use something like this instead:
static double rand01()
{
  int r;
  while((r=rand())==RAND_MAX);
  return (double)rand/RAND_MAX;
}
...
if(rand01()<(double)(10-fillers_used)/(60-i)){
...
Apart from this, the process is unbiased. To prove this, we can use a little probability. Let's call Pn the probability that the process uses a filler value at position n. Also, let p=10/60, q=1-(10/60).Then:

P0 = 10/60
P1 = P0·(9/59)+(1-P0)·(10/59) = (10/60)·(9/59)+(50/60)·(10/59) = 590/3540 = 10/60
Pn = pn·((10-n)/(60-n)) + pn-1·q·((10-(n-1))/(60-n)) + ··· + qn·(10/(60-n))

It can be formally proven that Pn = 10/60 for every n, but also a small test program doing the calculations will convince you.


Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
QuestionHow to show File Preview in the Windows Explorer. Pin
Ganesh Agrawal11-Jul-02 9:18
Ganesh Agrawal11-Jul-02 9:18 
AnswerRe: How to show File Preview in the Windows Explorer. Pin
KaЯl12-Jul-02 5:01
KaЯl12-Jul-02 5:01 
GeneralRe: How to show File Preview in the Windows Explorer. Pin
Ganesh Agrawal12-Jul-02 6:25
Ganesh Agrawal12-Jul-02 6:25 
GeneralWrong return type from CObList (newb question) Pin
EBerlin11-Jul-02 8:25
EBerlin11-Jul-02 8:25 
GeneralProblem Fixed Pin
EBerlin11-Jul-02 8:30
EBerlin11-Jul-02 8:30 
GeneralRe: Wrong return type from CObList (newb question) Pin
jbarton11-Jul-02 9:12
jbarton11-Jul-02 9:12 
GeneralRe: Wrong return type from CObList (newb question) Pin
EBerlin11-Jul-02 10:55
EBerlin11-Jul-02 10:55 
GeneralRe: Wrong return type from CObList (newb question) Pin
jbarton15-Jul-02 2:08
jbarton15-Jul-02 2:08 
QuestionOLE?? Pin
Kuniva11-Jul-02 7:52
Kuniva11-Jul-02 7:52 
AnswerRe: OLE?? Pin
Anonymous11-Jul-02 8:04
Anonymous11-Jul-02 8:04 
GeneralGetting DevStudio dependencies correct Pin
Jonathan Gilligan11-Jul-02 7:47
Jonathan Gilligan11-Jul-02 7:47 
GeneralRe: Getting DevStudio dependencies correct Pin
J Patel11-Jul-02 11:48
J Patel11-Jul-02 11:48 
GeneralACtiveX Guru's... Pin
Anonymous11-Jul-02 7:29
Anonymous11-Jul-02 7:29 
GeneralRe: ACtiveX Guru's... Pin
Bill Wilson11-Jul-02 11:56
Bill Wilson11-Jul-02 11:56 
GeneralArray of structure Pin
Richard Jones11-Jul-02 7:29
Richard Jones11-Jul-02 7:29 
GeneralRe: Array of structure Pin
Nish Nishant11-Jul-02 7:38
sitebuilderNish Nishant11-Jul-02 7:38 
GeneralRe: Array of structure Pin
Christian Graus11-Jul-02 12:06
protectorChristian Graus11-Jul-02 12:06 

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.