Author: Uri Blass
Date: 11:35:16 04/25/01
Go up one level in this thread
On April 25, 2001 at 14:29:54, Dann Corbit wrote:
>// stronger.cpp: Is your favorite player really stronger?
>// Programmed by Leen Ammeraal
>#include <iostream>
>#include <iomanip>
>#include <cmath>
>using namespace std;
>
>double binom(int n, int k)
>{ double x = 1;
> for (int j=0; j<k; ++j)
> x *= double(n - j) / (j + 1);
> return x;
>}
>
>int main()
>{ int n, nA, nB, nD;
> double p = 0.5;
> cout << "Player A may be stronger than player B "
> "or may have won by luck.\n";
> cout << "How many times has A won? ";
> cin >> nA;
> cout << "How many times has B won? ";
> cin >> nB;
> cout << "How many draws (preferably an even number)? ";
> cin >> nD;
> nA += nD/2;
> nB += nD/2;
> n = nA + nB;
> cout << "Our computation will be based on the score "
> << nA << " - " << nB << endl;
> double s = 0, t = 0;
>
> for (int i=0; i<=nB; ++i)
> { t = binom(n, i) * pow(p, i) * pow(1-p, n-i);
> // t is the probability of B obtaining i points.
> s += t;
> }
> // s is the probability of B obtaining nB points or less.
> // This is equal to the probability of A obtaining nA points
> // or more.
> cout << "If A and B had the same strength, the probability of A\n";
> cout << "obtaining this score (or better) would be equal to "
> << fixed << setprecision(1)
> << s * 100 << "%.\n";
> return 0;
>}
>/*
>E:\>stronger
>Player A may be stronger than player B or may have won by luck.
>How many times has A won? 5
>How many times has B won? 0
>How many draws (preferably an even number)? 0
>Our computation will be based on the score 5 - 0
>If A and B had the same strength, the probability of A
>obtaining this score (or better) would be equal to 3.1%.
>*/
You are right if the probability to win is 50% but practically it is clear that
there is a positive probability for a draw so 3.1% is only an upper bound in
case of equal programs.
I used the assumption that white has probability of 40% to win and black has
probability of 30% to win and got less than 0.5% probability to get 5-0 when 3
of the wins are with black.
Uri
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.