I thought this is a good lunch break exercise. http://www.decisionsciencenews.com/2017/06/19/counterintuitive-problem-everyone-room-keeps-giving-dollars-random-others-youll-never-guess-happens-next/
Quote: “Imagine a room full of 100 people with 100 dollars each. With every tick of the clock, every person with money gives a dollar to one randomly chosen other person. After some time progresses, how will the money be distributed?” And I came up with this simulation. (45 people with 45 dollars each, same as on the webpage.) /:~@(-&1`]@.(=&0)"0 (#/.~@] + ~.@]{[)`(~.@])`[} >&0 # (?@#~@#@]`]`[} ]I.@:=i.@#)^:_@?@#~@#)^:5000 #~45 And I really like to see the mean expectations and the standard deviation of the mean, I ended up doing this. (Make sure the J sentence is one long line if you want to try it out.) ((],.[:(+/%#*<:@#)&.:*: -"1)+/%#)}.(/:~@(-&1`]@.(=&0)"0 (#/.~@] + ~.@]{[)`(~.@])`[} >&0 # (?@#~@#@]`]`[} ]I.@:=i.@#)^:_@?@#~@#)^:10000)^:(<65) #~45 0.984375 0.124984 2.01562 0.170335 3.0625 0.180765 4.15625 0.230616 5.21875 0.248476 6.1875 0.306894 7.35938 0.332862 8.64062 0.362809 9.84375 0.380723 10.9688 0.383805 12.125 0.407944 13.6406 0.423964 15.0625 0.457453 16.5312 0.462893 18.1875 0.480717 19.7031 0.464877 21.1562 0.475709 22.7031 0.483702 24.4062 0.516935 26.4062 0.5768 28.1094 0.604266 29.8281 0.617838 31.875 0.61942 33.9375 0.603345 35.7812 0.642211 37.9844 0.647987 40.6562 0.731321 43 0.739342 45.3906 0.723616 48.0469 0.7613 51.6094 0.823639 54.7656 0.873934 57.1406 0.815544 60 0.866598 63.8594 0.898319 68.75 0.918018 73.5781 1.00736 78.3281 1.08128 84.9688 1.25534 93.4688 1.29731 104.578 1.73274 114.922 2.07574 131.938 2.7357 159.359 4.40899 204.766 7.24239 So, how do I make a fancy animation (like the one in the webpage I linked in the beginning of this message) with J? ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm