Original Post
I have a question about chances when flipping a coin
normaly you have 50/50 chance of it being HEAD or TAILES (or whatever its called in english)
so I have always been told that past experiments do not influence the outcome of future experiments, whell not with experiments like flipping coins. But I've written a testprogram that seems to indicated they do. Can anyone explain
HEAD RAND SMART
50.0002 % 49.9984 % 50.2997 %
50.0013 % 50.0017 % 50.301 %
50.0032 % 49.9971 % 50.2776 %
49.9989 % 50.0015 % 50.1646 %
49.9959 % 49.9979 % 50.3843 %
49.9987 % 50.0009 % 50.1927 %
50.0055 % 50.0001 % 50.1907 %
49.9986 % 49.9977 % 50.3278 %
49.998 % 50.0019 % 50.2863 %
49.9982 % 50.0012 % 50.3162 %
these are the results of 1.000.000 coinflips, that is per line, I start over
HEAD is %-age of coins with HEADS on top
RAND is a random guess, %-age is number of times guess is correct
SMART takes previous results in account, it just checks wich has occured least HEAD or TAILS, and picks that one
You can see theres about 0.2% more correct guesses with SMART
and its allways around that number even with 1.000.000.000 coinflips
Anyway heres the code
hey, maybe its just a problem with the random generator, but I dont think so
Edited by - fenrir on 12/20/00 5:58:30 PM
#include <iostream.h>
#include <iomanip.h>
#include <fstream.h>
#include <time.h>
#include <stdlib.h>
#define KOP 0
#define MUNT 1
#define NUM_THROW 1000000
int main()
{
double NT = NUM_THROW;
NT/=100.0;
int cKop, cMunt, cSmartGokJuist, cRandGokJuist;
srand(time(NULL));
int Worp, SmartGok, RandGok;
cout << "KOP\t\tRAND\t\tSMART"<<endl;
for (int cTest = 0; cTest < 10; cTest++)
{
cKop = cMunt = cSmartGokJuist = cRandGokJuist =0;
for (int cWorp = 0; cWorp < NUM_THROW; cWorp++)
{
Worp = rand()%2;
RandGok = rand()%2;
(cKop<cMunt)?SmartGok=KOP:SmartGok=MUNT;
if (SmartGok == Worp) cSmartGokJuist++;
if (RandGok == Worp) cRandGokJuist++;
(Worp==KOP)?cKop++:cMunt++;
}
cout << setiosflags( ios :: left) << setprecision(7) << setw(8)<< double(cKop)/NT << "%\t" << setw(8)<< double(cRandGokJuist)/NT << "%\t" << setw(8)<< double(cSmartGokJuist)/NT << "%" << endl;
}
char ch;
cin >> ch;
return 0;
}
|
--{You fight like a dairy farmer!}