Tag Info

New answers tagged

3

nextGen[n_] := Total@RandomChoice[{11/32, 3/8, 3/16, 3/32} -> {0, 1, 2, 3}, n] simulate[n0_, nrOfGenerations_] := Total@NestList[nextGen, n0, nrOfGenerations] Now we can simulate six generations a hundred times and compute the mean value. The initial number of organisms is 10 in this example. Table[simulate[10, 6], {100}] // Mean // N (* Out: 75.42 *) ...


13

Usage Just use this function with any polyhedron in in form: GraphicsComplex[pts_, Polygon[vertices_, ___]]. When I find time and motivation maybe I will add more DownValues so it can be more general. Atm you can play with solids given by PolyhedronData[... "Faces"]: polyhedronRandomWalk[ PolyhedronData["DuerersSolid", "Faces"] ] It ...


4

RandomChoice[{.9, .1} -> {1, 0}, 10] (* {0, 1, 1, 1, 1, 1, 1, 0, 1, 1} *) Timing results Timing[RandomVariate[BernoulliDistribution[.9], {10^8}];] (* {3.38014, Null} *) Timing[RandomChoice[{.9, .1} -> {1, 0}, 10^8];](* {5.64937, Null} *) dist[] := If[RandomReal[] > 0.9, 0, 1]; Timing[Table[dist[], {i, 10^8}];] (* {13.9842, Null} *) One nice ...


5

Take a uniform random distribution and check if it is above some threshold (0.9 in your case). For example: dist[] := If[RandomReal[] > 0.9, 0, 1]; Table[dist[], {i, 100}]


20

BernoulliDistribution is a perfect fit for this. RandomVariate[BernoulliDistribution[1 - 0.1], {50}] {1, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1} Also, as kguler states, you can use RandomChoice, but the benefit of BernoulliDistribution is that ...



Top 50 recent answers are included