MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Coin Toss Sim

  • To: mathgroup at smc.vnet.net
  • Subject: [mg122396] Re: Coin Toss Sim
  • From: Rui <rui.rojo at gmail.com>
  • Date: Thu, 27 Oct 2011 06:31:51 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • References: <j89v28$8e$1@smc.vnet.net>
  • Reply-to: comp.soft-sys.math.mathematica at googlegroups.com

Every place you write g it runs the RandomChoice code again. So, the values of g it uses when evaluating your s in {g, s} is not the same as the one it uses in the g in {g, s}.
You want the list for the same realization. I would write something like
y[n_]:=With[
    {g=RandomChoice[{"head", "tail"}, n]},
    {g, Count[g, "head"]}
    ]



  • Prev by Date: Combine sqrts in denominator
  • Next by Date: Re: Coin Toss Sim
  • Previous by thread: Re: Coin Toss Sim
  • Next by thread: Re: Coin Toss Sim