Hot answers tagged

15

This was a fun question to answer, even considering that I know nothing about general relativity. It's all a matter of translating the equations presented in this paper by Oliver James, Eugenie von Tunzelmann, Paul Franklin, and Kip Thorne into notebook expressions. Embedding Diagrams The paper gives some really cool figures to show the curvature of ...


12

Let's say that both players start with 10 dollars. We can represent the game state with a list: start = {10, 10}; Create a function which plays one round of the game. There are only two possible outcomes, we can use RandomChoice to pick randomly between them: oneRound[{x_, y_}] := RandomChoice[{{x + 1, y - 1}, {x - 1, y + 1}}] For example ...


8

There is an example in the documentation which may get you started: pairs = RandomReal[{-1, 1}, {10000, 2}]; 4 Count[Map[Norm, pairs], _?(# <= 1 &)]/10000. (*3.1248*) You can plot see this as: Graphics[{PointSize[Small], Blue, Point@Select[pairs, Norm[#] <= 1 &], Gray, Point@Select[pairs, Norm[#] > 1 &], Red, Thick, Circle[]}, ...


7

Here is an approach using RandomPoint and graphics primitives: pts = RandomPoint[Rectangle[], 10^6]; (* generate random points on the unit square *) rm = RegionMember[Disk[{0.5, 0.5}, 0.5]]; (* RegionMemberFunction for an embedded Disk *) Now we count the number of points that fall in the circle and divide that by the total number of points. That should ...


7

Here is a way to generate the mesh including region markers and different refinement in different regions: Needs["NDSolve`FEM`"] L = 1; i1 = 0.625; i2 = 0.25; (bmesh = ToBoundaryMesh[ "Coordinates" -> {{0, -L}, {10, -L}, {10, -L + i1}, {11, -L + i2}, {11, L - i2}, {10, L - i1}, {10, L}, {0, L}, {10, -5}, {12, -5}, {12, 5}, {10, 5}}, ...


6

This is not answer, but an extremely long comment. I find this problem very interesting, but haven't been able to solve it. In my attempts, I developed a tool to visualize the the two-walker random walk. I am posting this tool because I think it might be useful to the OP or anyone else looking this problem for exploring what's going on. steps = {{0, 1}, ...


3

Does this do what you want? stepTypes = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}; {pos1, pos2} = RandomInteger[{0, 4}, {2, 2}]; While[pos1 != pos2, {pos1, pos2} = Mod[{pos1, pos2} + RandomChoice[stepTypes, 2], 5]; Print[pos1, pos2];]


3

Below is a workaround for the simple case. The OP can say whether it works more general. I haven't quite tracked down yet why the system is set up incorrectly with the default Method -> {"EquationSimplification" -> "Solve"} and with Method -> {"EquationSimplification" -> "Residual"}. But it works in this case with Method -> ...


1

The discrepancy had to do with the way the walkers were subsequently moved. You have to either move synchronously (on separate threads perhaps) or you have to make it check for a specific case where the walkers are exactly one step away and their next step is towards each other. In other words, if they swap positions then there was a collision. Thanks ...


1

Here is my code for a single walker: singleWalker[] := Module[{ stepTypes = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}}, pos1 = RandomInteger[{0, 4}, 2] }, Return@Rest@NestWhileList[ Mod[# + RandomChoice[stepTypes], 5] &, pos1, # != {2, 2} & ]; ] Doing walks = (singleWalker[] & /@ Range[1000]); and measuring N@Mean[Length /@ ...



Only top voted, non community-wiki answers of a minimum length are eligible