Re: Coin Toss Sim
- To: mathgroup at smc.vnet.net
- Subject: [mg122413] Re: Coin Toss Sim
- From: "Dr. Wolfgang Hintze" <weh at snafu.de>
- Date: Fri, 28 Oct 2011 05:32:38 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <j89v28$8e$1@smc.vnet.net>
"pooleman133" <poolebc221 at gmail.com> schrieb im Newsbeitrag news:j89v28$8e$1 at smc.vnet.net... >I am new to mathematica and am trying to make a coin flipping >simulation however mo code isn't working. When I tell it to count the >number of head it gives me a bad count. The code I am using is listed >below any help would be greatly appreciated. > > y[n_] := Block[{g, s}, > > > g := RandomChoice[{"head", "tail"}, n]; > s := Count[g, "head"]; > {g, s} > ] > If I avoid RandomChoice it works fine: y[n_] := Block[{g, s}, g := Table[If[Random[] < 1/2, "head", "tail"], {n}]; s := Count[g, "head"]; {g, s}] y[10] {{"tail", "head", "head", "head", "tail", "tail", "tail", "head", "head", "tail"}, 3} -- Wolfgang
- Follow-Ups:
- Re: Coin Toss Sim
- From: Dan Dubin <ddubin@ucsd.edu>
- Re: Coin Toss Sim
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Coin Toss Sim