How to simulate random samples from crooked coin toss?

Discussion in 'Mathematica' started by DAN BIKLE, Jul 5, 2005.

  1. DAN BIKLE

    DAN BIKLE Guest

    Math People,

    I'm new to Mathematica so please bear with me.

    I have a simple problem I want to solve and I'm looking
    for some ideas to get started on it.

    I want to simulate 100 tosses of a crooked coin where
    probability of Heads is 0.6 and Tails is 0.4.

    After I figure the coin out, I want to move on to crooked
    dice and crooked card decks.

    So, really what I'm looking for has more to do with developing
    a method to simulate the collection of random samples.

    I looked around in Help and found a promising sentence:

    "Random[distribution] gives a random number with the specified
    statistical distribution."

    Then I found a page here which has some clues:
    http://mathworld.wolfram.com/DiscreteDistribution.html

    Unfortunately, I'm weak with math notation so the above
    page makes little sense to me.

    So, let me put it to you as simply as I can:

    I want to define a function that could be called like this:

    numberOfHeads = coinTosser[infoAboutCoin, numberOfTosses, head]
    numberOfTails = coinTosser[infoAboutCoin, numberOfTosses, tail]

    Once I figure out how to write the above function,
    I could template off of it to build something like this:

    numberOfOnes = diceRoller[infoAboutThisDie, numberOfRolls, aOne]

    Do any of you have thoughts on how to approach the
    writing of the above functions?

    -Dan
     
    DAN BIKLE, Jul 5, 2005
    #1
    1. Advertisements

  2. Hi,

    say a 1 mean a head and a 0 mean a tail than

    HeadOrTail[]:=If[Random[]<0.6,1,0]

    will generate one realisation of your random
    variable
    and with
    sample = Table[HeadOrTail[], {1000}];

    you get a sample of the random variable,
    here is the number of "heads" in the sample
    Count[sample, 1]

    and here the number of tails

    Count[sample, 0]

    Regards

    Jens
     
    Jens-Peer Kuska, Jul 5, 2005
    #2
    1. Advertisements

  3. DAN BIKLE

    dh Guest

    Hi Dan,

    If you want to simulate the coin tossing problem, remember that
    Random[ ] gives a uniformly distributed pseudorandom Real in the range 0
    to 1.
    Therefore, if we want to simulate an event with probability P, we check
    if the outcome of Random is below P or not. E.g.
    How many heads in n tosses with a crooked coin with P=0.6:

    Count[ Table[ If[Random[]<P,1,0] ,{n} ] ,1]

    For y dice, you would check if the outcome of Random =x is:
    x<1/6, 1/6<=x<2/6,..
    depending on how many eyes you want.

    An additional note:
    if you only want a function like:
    the problem can be solved without simulations
    For your purpose, to describe a coin (dice, cards) you have to specify
    the propability that a certain event happens, e.g. "Head", call it Ph. A
    fine coin would have Ph=0.5, a croocked coin e.g. Ph=0.6.
    Now as your coin tosses are all independent, the mean number of Heads in
    n tosses will simply be: n Ph

    sincerely, Daniel

     
    dh, Jul 6, 2005
    #3
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.