# Tag Info

4

Definitely something interesting going on here. c[x_] := Count[Table[RandomSample[{100000, 0, 1} -> {1, 2, 3}, 1], {x}], {3}] DiscretePlot[c[x]/x, {x, 10, 400}] Note that changing the zero weight to something greater than zero seems to give the expected behavior. Some experimentation seems to suggest that adding a zero weight in the presence of ...

6

It inverts the CDF by binary search.

3

You might find (if you've not already read it) Random Number Generation from the Wolfram tutorial collection interesting. Slightly dated but relevant, covers how Mathematica generally uses inverse CDF for such things until it deems that expensive, then switching to table-lookup or direct generation. Probably worth a ping to support, they seem pretty open ...

6

It's just the histogram's default binning that isn't always divisible by the number of distinct values you have Try with hist = Histogram[#, Nearest[Divisors@Length@Union@#, 20]] &, but you will quite often get ugly (unaveraged or overaveraged) results, because more often than not there just isn't an exact divisor thats near a nice number of bins. The ...

2

BlockRandom simply isolates anything affecting random number generation, etc. that is changed (like seeding). If you do nothing, there's nothing to isolate, and if you do nothing, the results will be the same as outside such a block: the second list gets subsequent random variates from the stream. Use SeedRandom like so (snippet of your code modified): ...

0

Shooting points at the diagram and determining the fraction inside any of the nested circles may be the beginnings of a Monte Carlo determination of the area fraction of the infinite series of circles. If so (and it's probably a very big if), consider the triangle with side lengths $a$, $b$, $c$. The inradius $r$ of the incircle is \$r = ...

7

Fixing the edge length makes the problem harder. Otherwise, maybe this here gives an idea << ComputationalGeometry data = .9 Flatten[ Table[{x, y} + .07 RandomReal[{-1, 1}, {2}], {x, -1, 1, .2}, {y, -1, 1, .2}], 1]; delval = DelaunayTriangulation[data]; convexHull = ConvexHull[data]; gr = DiagramPlot[data, ##, LabelPoints -> False] ...

13

Since this is rather long, some might prefer a teaser of what is coming: Introduction First of all, I don't really know why you make your figure inconsistent. I mean, from the first big triangle you separate three smaller triangles. Why don't you just repeat this process and inscribe a circle in each of the new triangles and again separate three new ...

5

NExpectation[ Max[(S12 + S1)/2 - 100, 0], {S1, S12} \[Distributed] SliceDistribution[ GeometricBrownianMotionProcess[r, sigma, S0], {1/2, 1}], Method -> "MonteCarlo"] or NExpectation[ Max[(S12 + S1)/2 - 100, 0], {S1, S12} \[Distributed] SliceDistribution[ GeometricBrownianMotionProcess[r, sigma, S0], {1/2, 1}], Method -> {"NIntegrate", ...

2

This uses the second argument of dynamics, which acts like an event call back. In there, you do the specific action needed when that dynamic changes. This localizes the logic with its own control variable. Makes it easier to manage. If you like more information about this method, see this question But you really need to fix/improve the way the function ...

0

The kind of Manipulate you want to build can be made by taking a state-machine approach and using Refresh with the option TrackedSymbols Here is a relatively brief working example: SeedRandom[42]; Manipulate[ Row[{ Dynamic@Refresh[ If[event != "idle", update[]]; Column[{plot, mean}], TrackedSymbols -> {event}], ...

1

Id suggest it will be far more efficient if you do rank=Ordering@list1; then you can access the rank directly, ie rank[[1]] -> same as Position[list1,1][[1,1]] If you really intend to process all 90 billion permutations this i think will make a big difference vs calling Position 14 times.

4

Update - general function, description at the end ClearAll[LightlikeVectorsThatSumUpToZero]; LightlikeVectorsThatSumUpToZero[n_Integer: 5] := Module[ {m, p, eq, set, sol, res, s = 4}, While[ m = Array[p, {n, s}]; m[[2 ;;, 2 ;;]] = RandomReal[{-1, 1}, {n - 1, s - 1}]; m[[2, 2]] = p[2, 2]; (# = -Total[{##2}]) & @@@ Transpose[m][[3 ...

0

OK, so here is a really scetchy solution (up to numerical accuracy). It can compute the requested vectors not only in the case of 5 vectors, but for arbitrary number (set variable point to the desired value). Remove["Global*"] point = 7; SeedRandom; rnd[x_] := RandomReal[{-10, 10}]; mat = {}; Do[mat = Append[ mat, {Subscript[p0, i], sg Subscript[p1, i], ...

1

I ended up solving this using the algorithm below. This was rather complicated (which is why I'm only describing the process, and have omitted both the actual code and several small details), so maybe there's a better way. 1) Randomly pick the critical points, with the restriction that their slopes have to have absolute value between 1 and 3, and that ...

0

This goofy way will let you specify how many to generate, the maximum power of x, and the +/- range of coefficients to use (excluding zero): Plus @@@ Table[(RandomInteger[{-#3, #3 - 1}] /. (0 -> #3)) x^s, {#1}, {s, 0, #2}] &[5, 2, 10] (* {-4 + 10 x - x^2, -10 - 5 x + 6 x^2, 5 - 6 x + 10 x^2, -8 - 9 x - 5 x^2, -6 - 9 x - 5 x^2} *) Same result, ...

3

Here's a slightly different method. Except for the fact that you want non-zero integers, RandomInteger would be perfect for this, e.g. len = 5; RandomInteger[{-10, 10}, {len, 3}] (* {{-3, -2, 10}, {2, -3, -8}, {5, 3, -2}, {9, 3, -2}, {-9, 3, -6}} *) which gives your list of triples directly. Now, you could alter the range and make substitutions like Yi ...

2

Here is a rough way to achieve this: RandomPolynomial[max_Integer, var_Symbol] := Module[{pol, lis}, lis = Table[RandomChoice@Join[Range[-10, -1], Range[10]] var^deg, {deg, max,0, -1}]; pol = Tr@lis] Now let's create 25 of these: Table[RandomPolynomial[2, x], {25}]

3

rand := RandomInteger[{-10, 9}] /. (0 -> 10) eq := rand x^2 + rand x + rand Array[eq &, {25}] {5 - 3 x - 6 x^2, -9 - 6 x + 5 x^2, -2 - 6 x + 9 x^2, 7 - 6 x + 9 x^2, 2 + 8 x + 8 x^2, 3 - x + 5 x^2, -10 + 4 x - 5 x^2, -4 + 6 x + 10 x^2, 2 - 5 x - 5 x^2, -7 - 2 x - 8 x^2, -7 - 4 x - 6 x^2, -1 - 2 x + 7 x^2, 8 - 2 x + x^2, 5 + 2 x + ...

Top 50 recent answers are included