[Jprogramming] Everyone giving dollars to random others
Devon McCormick
devonmcc at gmail.com
Mon Jul 10 21:17:42 UTC 2017
So, you start with $10,000 (=100*$100) but end up with $2,025 (=45*$45),
how?
On Mon, Jul 10, 2017 at 3:59 PM, Raul Miller <rauldmiller at gmail.com> wrote:
> I don't really understand what you mean by "mean expectations" - could
> you describe the intent there?
>
> That said, here's how far I've gotten in implementing this concept:
>
> tick=: (0 >. <:) + i.@# +/@:(=/)~ +/@:* ?@# #
> (mean,stddev)"1 tick^:(i.10)]100#100
> 100 0
> 100 0.932034
> 100 1.41421
> 100 1.91749
> 100 2.07437
> 100 2.34844
> 100 2.48633
> 100 2.71546
> 100 2.97803
> 100 3.26289
>
> (Also, for animation in J, there's actually a lot of options...
> basically though you set up a paint event which calls into your
> rendering code and then trigger updates from systimer.)
>
> Thanks,
>
> --
> Raul
>
> On Mon, Jul 10, 2017 at 3:43 PM, Xiao-Yong Jin <jinxiaoyong at gmail.com>
> wrote:
> > 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
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>
--
Devon McCormick, CFA
Quantitative Consultant
More information about the Programming
mailing list