Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #5998
| From | DrMajorBob <btreat1@austin.rr.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Coin Toss Sim |
| Date | 2011-10-29 11:20 +0000 |
| Organization | Steven M. Christensen and Associates, Inc and MathTensor, Inc. |
| Message-ID | <j8gnh5$5en$1@smc.vnet.net> (permalink) |
| References | <j89v28$8e$1@smc.vnet.net> <201110280932.FAA20605@smc.vnet.net> |
Wolfgang,
No, that doesn't work, as your output shows... a list with 5 heads but a
count of 3.
Bobby
On Fri, 28 Oct 2011 04:32:38 -0500, Dr. Wolfgang Hintze <weh@snafu.de>
wrote:
>
> "pooleman133" <poolebc221@gmail.com> schrieb im Newsbeitrag
> news:j89v28$8e$1@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
>
>
--
DrMajorBob@yahoo.com
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Coin Toss Sim pooleman133 <poolebc221@gmail.com> - 2011-10-26 21:45 +0000
Re: Coin Toss Sim Rui <rui.rojo@gmail.com> - 2011-10-27 10:40 +0000
Re: Coin Toss Sim "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-28 09:33 +0000
Re: Coin Toss Sim "Dr. Wolfgang Hintze" <weh@snafu.de> - 2011-10-29 11:21 +0000
Re: Coin Toss Sim Dan Dubin <ddubin@ucsd.edu> - 2011-10-29 11:15 +0000
Re: Coin Toss Sim DrMajorBob <btreat1@austin.rr.com> - 2011-10-29 11:20 +0000
Re: Coin Toss Sim "Chris Degnen" <degnen@cwgsy.net> - 2011-11-01 05:10 +0000
Re: Coin Toss Sim David Bailey <dave@removedbailey.co.uk> - 2011-11-02 11:27 +0000
csiph-web