Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #14653 > unrolled thread

Re: tossing a coin

Started bymichael partensky <partensky@gmail.com>
First post2013-05-28 07:45 +0000
Last post2013-05-30 10:08 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: tossing a coin michael partensky <partensky@gmail.com> - 2013-05-28 07:45 +0000
    Re: tossing a coin Felipe <fdimer@gmail.com> - 2013-05-30 10:08 +0000

#14653 — Re: tossing a coin

Frommichael partensky <partensky@gmail.com>
Date2013-05-28 07:45 +0000
SubjectRe: tossing a coin
Message-ID<ko1nbl$r31$1@smc.vnet.net>
Dear Leigh. The first part of you statement is correct (assuming a fair
coin). Unfortunately, the second part ("The probability of one occurring
before the other is 50%") is a common misconception, one of many counter-intuitive features of  randomness. You can find a useful introduction here:
http://www.mathematica-journal.com/2011/09/betting-two-patterns-against-each-other/
 .

Even less intuitive could be the results for a  loaded coin. For example,
assume P(H)=0.6 and P(T) = 0.4. You might think that the bet on the pattern
HHH would always be winning relative to say THH, which happens to be false.

My question was about an elegant,  *Mathematica* style (preferably, without
Do, While) detection of the first occurrence of a pattern for (in general)
loaded (sorry, I forgot to mention this part in my question) coin. From
this discussion I hoped to learn more about the best practices of dealing
with patterns in sequences (my own experience is outdated), and hear some
thoughts on statistics of patterns.

Best,
Michael Partenskii




On Mon, May 27, 2013 at 4:45 AM, leigh pascoe <leigh@evry.inserm.fr> wrote:

> Le 26/05/2013 11:08, michael partensky a =E9crit :
> > Hi everybody!
> > Here is a classical problem:
> >
> > A and B take turns flipping a coin. H and T designate "heads" and "tails"
> > respectively.
> > Each of them chooses a pattern. Say, A picks HHTT and B picks HTHT (the
> > length of the fragment may vary). One wins if his pattern appears before
> > the pattern of his opponent.
> >
> > For any two patterns we have to find the answer *experimentally (by
> > producing many random sequences and computing the frequencies of wins)*.
> > What would be the most elegant way of detecting the first appearance of a
> > pattern ?
> >
> > Thanks,
> > Michael Partenskii
> >
> >
> >
> The probability of any given sequence is the same as any other,
> depending only on its length. The probability of one occurring before
> the other is 50%. I don't think you need Mathematica to solve this problem.
>
> Or did I misinterpret your problem?
>
> Leigh
>

[toc] | [next] | [standalone]


#14676

FromFelipe <fdimer@gmail.com>
Date2013-05-30 10:08 +0000
Message-ID<ko78fd$dvb$1@smc.vnet.net>
In reply to#14653
Hi,

A variation of Dana's answer, if you'd like to keep the tossing results as a list

In[2]:= k = RandomChoice[{"h", "t"}, 30]

Out[2]= {"t", "h", "h", "h", "t", "t", "h", "t", "h", "h", "h", "t", \
"t", "t", "t", "h", "t", "h", "h", "t", "t", "t", "h", "h", "t", "h", \
"t", "t", "t", "h"}

In[8]:= k //. {x___, "t", "h", "h", y___} :> {x, "PATTERN A", y}

Out[8]= {"PATTERN A", "h", "t", "t", "h", "PATTERN A", "h", "t", "t", \
"t", "t", "h", "PATTERN A", "t", "t", "PATTERN A", "t", "h", "t", \
"t", "t", "h"}


A more literal way is to create the sequences by partitioning with padding

In[29]:= Position[Partition[k, 3, 1], {"t", "h", "h"}]

Out[29]= {{1}, {8}, {17}, {22}}

Best Regards

[toc] | [prev] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web