Re: [math-fun] how to test whether a coin is fair
Gene has it exactly right: a) you need to decide what you mean by 'fair' ... Expectation of a Head = 0.5 +- epsilon ... but what's epsilon? b) Bayesian inference totally takes care of this just decide what your prior belief in the coin is .... e.g., it's Probability of throwing a Head is 'x' ... for all x ... i.e. you know nothing to start with Of course, if it's not fair, you'll be tossing it a long time and getting increasingly incredulous. [ Greece will tell you that if it's a Euro, you don't need to toss it - it's not fair :-) ] Guy
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
Now this is moving beyond just testing the fairness of a coin, and into testing the fairness of the coin tossing process. -- Gene From: David Makin <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Sent: Friday, March 4, 2016 3:06 PM Subject: Re: [math-fun] how to test whether a coin is fair I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
Expanding on what Gene said: 1. no real physical coin is fair, the question is, how unfair is it. 2. for a coin that is close to being fair, the tossing mechanism and how it varies with each toss have to be taken into account. Even with a spring-loaded mechanical thumb, there will be variations due to metal fatigue, friction in the release mechanism, air temperature, etc. Best regards Neil Neil J. A. Sloane, President, OEIS Foundation. 11 South Adelaide Avenue, Highland Park, NJ 08904, USA. Also Visiting Scientist, Math. Dept., Rutgers University, Piscataway, NJ. Phone: 732 828 6098; home page: http://NeilSloane.com Email: njasloane@gmail.com On Sat, Mar 5, 2016 at 10:07 AM, Adam P. Goucher <apgoucher@gmx.com> wrote:
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
Suppose, for some reason, you need to generate random variables whose normalized probability distribution is P(z) = (1/pi) BesselK[0] ( |z| ). Here's a clever way to do it without having to muck with Bessel functions. Let x and y be independent Gaussian random variables with zero mean and unit variance. Then z = xy has the desired distribution. Furthermore, the sum of n such products, has distribution P[n](z) = (1 / (sqrt(pi) Gamma(n/2)) (|z| / 2)^((n-1)/2) BesselK[((n-1)/2] ( |z| ). -- Gene
Interesting (though I've never needed a Bessel distribution). I wonder what the distribution is of the product of n i.i.d. N(0,1) random variables is. —Dan
On Mar 5, 2016, at 12:25 PM, Eugene Salamin via math-fun <math-fun@mailman.xmission.com> wrote:
Suppose, for some reason, you need to generate random variables whose normalized probability distribution is
P(z) = (1/pi) BesselK[0] ( |z| ).
Here's a clever way to do it without having to muck with Bessel functions. Let x and y be independent Gaussian random variables with zero mean and unit variance. Then z = xy has the desired distribution.
Furthermore, the sum of n such products, has distribution
P[n](z) = (1 / (sqrt(pi) Gamma(n/2)) (|z| / 2)^((n-1)/2) BesselK[((n-1)/2] ( |z| ).
While I haven't worked this out for Gaussian random variables, it is easy to get the distribution of the product of n independent random variables uniform on [0,1]. It is p[n](x) = (-log x)^(n-1) / (n-1)! The singularity at 0 should be the same for a Gaussian, and indeed for x near 0 (and > 0) K[0](x) ~ -log x + constant. -- Gene From: Dan Asimov <asimov@msri.org> To: Eugene Salamin <gene_salamin@yahoo.com>; math-fun <math-fun@mailman.xmission.com> Sent: Saturday, March 5, 2016 12:53 PM Subject: Re: [math-fun] How to generate a random variable with a BesselK[0] distribution Interesting (though I've never needed a Bessel distribution). I wonder what the distribution is of the product of n i.i.d. N(0,1) random variables is. —Dan
On Mar 5, 2016, at 12:25 PM, Eugene Salamin via math-fun <math-fun@mailman.xmission.com> wrote:
Suppose, for some reason, you need to generate random variables whose normalized probability distribution is
P(z) = (1/pi) BesselK[0] ( |z| ).
Here's a clever way to do it without having to muck with Bessel functions. Let x and y be independent Gaussian random variables with zero mean and unit variance. Then z = xy has the desired distribution.
Furthermore, the sum of n such products, has distribution
P[n](z) = (1 / (sqrt(pi) Gamma(n/2)) (|z| / 2)^((n-1)/2) BesselK[((n-1)/2] ( |z| ).
p[1](x) = 1 ? On 17-Mar-16 16:21, Eugene Salamin via math-fun wrote:
While I haven't worked this out for Gaussian random variables, it is easy to get the distribution of the product of n independent random variables uniform on [0,1]. It is
p[n](x) = (-log x)^(n-1) / (n-1)!
The singularity at 0 should be the same for a Gaussian, and indeed for x near 0 (and > 0)
K[0](x) ~ -log x + constant.
-- Gene
From: Dan Asimov <asimov@msri.org> To: Eugene Salamin <gene_salamin@yahoo.com>; math-fun <math-fun@mailman.xmission.com> Sent: Saturday, March 5, 2016 12:53 PM Subject: Re: [math-fun] How to generate a random variable with a BesselK[0] distribution
Interesting (though I've never needed a Bessel distribution).
I wonder what the distribution is of the product of n i.i.d. N(0,1) random variables is.
—Dan
On Mar 5, 2016, at 12:25 PM, Eugene Salamin via math-fun <math-fun@mailman.xmission.com> wrote:
Suppose, for some reason, you need to generate random variables whose normalized probability distribution is
P(z) = (1/pi) BesselK[0] ( |z| ).
Here's a clever way to do it without having to muck with Bessel functions. Let x and y be independent Gaussian random variables with zero mean and unit variance. Then z = xy has the desired distribution.
Furthermore, the sum of n such products, has distribution
P[n](z) = (1 / (sqrt(pi) Gamma(n/2)) (|z| / 2)^((n-1)/2) BesselK[((n-1)/2] ( |z| ).
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
That's the probability density, not the cumulative density. —Dan
On Mar 18, 2016, at 5:14 AM, Mike Speciner <ms@alum.mit.edu> wrote:
p[1](x) = 1 ?
On 17-Mar-16 16:21, Eugene Salamin via math-fun wrote:
While I haven't worked this out for Gaussian random variables, it is easy to get the distribution of the product of n independent random variables uniform on [0,1]. It is
p[n](x) = (-log x)^(n-1) / (n-1)!
The singularity at 0 should be the same for a Gaussian, and indeed for x near 0 (and > 0)
K[0](x) ~ -log x + constant.
-- Gene
From: Dan Asimov <asimov@msri.org> To: Eugene Salamin <gene_salamin@yahoo.com>; math-fun <math-fun@mailman.xmission.com> Sent: Saturday, March 5, 2016 12:53 PM Subject: Re: [math-fun] How to generate a random variable with a BesselK[0] distribution Interesting (though I've never needed a Bessel distribution).
I wonder what the distribution is of the product of n i.i.d. N(0,1) random variables is.
—Dan
On Mar 5, 2016, at 12:25 PM, Eugene Salamin via math-fun <math-fun@mailman.xmission.com> wrote:
Suppose, for some reason, you need to generate random variables whose normalized probability distribution is
P(z) = (1/pi) BesselK[0] ( |z| ).
Here's a clever way to do it without having to muck with Bessel functions. Let x and y be independent Gaussian random variables with zero mean and unit variance. Then z = xy has the desired distribution.
Furthermore, the sum of n such products, has distribution
P[n](z) = (1 / (sqrt(pi) Gamma(n/2)) (|z| / 2)^((n-1)/2) BesselK[((n-1)/2] ( |z| ).
math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
I think the canonical Douglas Adams-ish phrase here would be "... without all that tedious mucking about with Bessel functions." Jim On Saturday, March 5, 2016, Eugene Salamin via math-fun < math-fun@mailman.xmission.com <javascript:_e(%7B%7D,'cvml','math-fun@mailman.xmission.com');>> wrote:
Here's a clever way to do it without having to muck with Bessel functions. Let x and y be independent Gaussian random variables with zero mean and unit variance. Then z = xy has the desired distribution.
Furthermore, the sum of n such products, has distribution
P[n](z) = (1 / (sqrt(pi) Gamma(n/2)) (|z| / 2)^((n-1)/2) BesselK[((n-1)/2] ( |z| ).
-- Gene
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
I think Diaconis has done some in-depth study on this, doing many coin flips (and dice rolls?) and videotaping them flipping in the air. Charles Greathouse Analyst/Programmer Case Western Reserve University On Sat, Mar 5, 2016 at 10:19 AM, Neil Sloane <njasloane@gmail.com> wrote:
Expanding on what Gene said:
1. no real physical coin is fair, the question is, how unfair is it.
2. for a coin that is close to being fair, the tossing mechanism and how it varies with each toss have to be taken into account. Even with a spring-loaded mechanical thumb, there will be variations due to metal fatigue, friction in the release mechanism, air temperature, etc.
Best regards Neil
Neil J. A. Sloane, President, OEIS Foundation. 11 South Adelaide Avenue, Highland Park, NJ 08904, USA. Also Visiting Scientist, Math. Dept., Rutgers University, Piscataway, NJ. Phone: 732 828 6098; home page: http://NeilSloane.com Email: njasloane@gmail.com
On Sat, Mar 5, 2016 at 10:07 AM, Adam P. Goucher <apgoucher@gmx.com> wrote:
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
Because the ref who tossed it claims it didn't flip and insists on doing it again. On Mar 5, 2016 7:08 AM, "Adam P. Goucher" <apgoucher@gmx.com> wrote:
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
? even with no internal state change we know that say probabilities of 2 tosses giving hh, ht, th and tt *ought* to be equal in the long term. On 5 Mar 2016, at 15:07, Adam P. Goucher wrote:
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
The meaning and purpose of life is to give life purpose and meaning. The instigation of violence indicates a lack of spirituality.
Actually I'd guess an adaptation of Lyapanov's test would probably work for an increasing number of tosses. The meaning and purpose of life is to give life purpose and meaning. The instigation of violence indicates a lack of spirituality.
If just using counts of h and t and number of tosses n, then I'd suggest that estimated chance of coin being unfair is abs(h-t)/n which should converge to 0 for a fair coin and otherwise give an increasingly accurate estimate of unfairness for larger n. On 6 Mar 2016, at 07:42, David Makin wrote:
? even with no internal state change we know that say probabilities of 2 tosses giving hh, ht, th and tt *ought* to be equal in the long term.
On 5 Mar 2016, at 15:07, Adam P. Goucher wrote:
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
The meaning and purpose of life is to give life purpose and meaning. The instigation of violence indicates a lack of spirituality.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
The meaning and purpose of life is to give life purpose and meaning. The instigation of violence indicates a lack of spirituality.
If the coin has no internal state, then the sequence of tosses are necessarily i.i.d. random variables. Subject to the (true!) assumption of the tosses being i.i.d., the *only* information you discern from the sequence of outcomes is the multiset of outcomes -- or equivalently the number of heads and number of tails. (Even for a biased coin, P(HT) = P(TH) = sqrt(P(TT) * P(HH)) and so on.) Best wishes, Adam P. Goucher
Sent: Sunday, March 06, 2016 at 7:42 AM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
? even with no internal state change we know that say probabilities of 2 tosses giving hh, ht, th and tt *ought* to be equal in the long term.
On 5 Mar 2016, at 15:07, Adam P. Goucher wrote:
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
The meaning and purpose of life is to give life purpose and meaning. The instigation of violence indicates a lack of spirituality.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
There is a classic paper "Inference for a Bernoulli Process (A Bayesian View) by Dennis Lindley and L.D. Phillips in the American Statistician vol. 30 no. 3, 1976, pp. 112-119 which treats exactly the problem of determining if a coin is fair, and contrasts the Bayesian approach with frequentist approach. Victor PS. For those of you with access to jstor, it's on there. On Tue, Mar 8, 2016 at 12:10 PM, Adam P. Goucher <apgoucher@gmx.com> wrote:
If the coin has no internal state, then the sequence of tosses are necessarily i.i.d. random variables. Subject to the (true!) assumption of the tosses being i.i.d., the *only* information you discern from the sequence of outcomes is the multiset of outcomes -- or equivalently the number of heads and number of tails.
(Even for a biased coin, P(HT) = P(TH) = sqrt(P(TT) * P(HH)) and so on.)
Best wishes,
Adam P. Goucher
Sent: Sunday, March 06, 2016 at 7:42 AM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
? even with no internal state change we know that say probabilities of 2 tosses giving hh, ht, th and tt *ought* to be equal in the long term.
On 5 Mar 2016, at 15:07, Adam P. Goucher wrote:
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
The meaning and purpose of life is to give life purpose and meaning. The instigation of violence indicates a lack of spirituality.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
The successive flips might exhibit correlation because of the way you pick up the coin or place it on your finger. Magicians practice flipping coins consistently so that, if they are catching the coin they can make up come up the same almost every time and to do that of course they start with the same side up each time. Brent On 3/5/2016 7:07 AM, Adam P. Goucher wrote:
Because each time you toss a coin, its internal state changes?
Sent: Friday, March 04, 2016 at 11:06 PM From: "David Makin" <makinmagic@tiscali.co.uk> To: math-fun <math-fun@mailman.xmission.com> Subject: Re: [math-fun] how to test whether a coin is fair
I'd guess that you'd actually have to check the evenness of all sample rates, not just a "1" and a "0" but also "00" vs. "01" vs. "10" vs. "11" and "000" vs."001" etc............... i.e, use the same check as for checking the randomness of a pseudo random generator.
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
_______________________________________________ math-fun mailing list math-fun@mailman.xmission.com https://mailman.xmission.com/cgi-bin/mailman/listinfo/math-fun
participants (13)
-
Adam P. Goucher -
Brent Meeker -
Charles Greathouse -
Dan Asimov -
Dan Asimov -
David Makin -
Eugene Salamin -
Guy Haworth -
James Propp -
Mike Speciner -
Neil Sloane -
Tom Rokicki -
Victor Miller