Hi Raul, "But is it possible to perform this calculation in a reasonable fashion using d. (or D.)?"
I'm no expert, but I doubt it. In the first answer to the question in your link, the user gave a comprehensive answer for calculating the case of a unit square. I think it can be extended to the case for any dimension (just more integrals). I'm not entirely sure how he evaluated the integral. But anyway it's a double integral, and I'm not sure how d. or D. can work with double integrals. I doubt it's possible. And it only gets worse for a cube etc, cus you'll have a triple integral etc. Regards -------------------------------------------- On Tue, 7/5/16, Raul Miller <[email protected]> wrote: Subject: [Jprogramming] Average distance between two points in a square To: "Programming forum" <[email protected]> Date: Tuesday, July 5, 2016, 5:28 AM I was looking at http://math.stackexchange.com/questions/1294800/average-distance-between-two-randomly-chosen-points-in-unit-square-without-calc and I was wondering how one might perform this calculation in J. It is, of course, fairly straightforward to approximate: (+/ %#)+/&.:*:@:(-/)?2 2 1e7$0 0.521401 And, you can just plug in the result given there: (1%15)*(2+]+5*[:^.1+])%:2 0.521405 But is it possible to perform this calculation in a reasonable fashion using d. (or D.)? More specifically, though, I would like to derive a version of this which works for arbitrary dimension (line, square, cube, tesseract, etc.) But so far my attempts in that direction have just gotten me domain errors. Perhaps what I should do is just sit down and derive the first four values of that sequence and then see if a pattern stands out. But before I did this, I thought I should check if this sort of thing strikes someone else as being either familiar or interesting. Thanks, -- Raul ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
