The problem is, it converges very slowly. After 1 billion trials, it has still only rendered (at most) 5 significant digits. And plus or minus 1 place in that 5th digit is still a stunningly large margin of error:
[0] Perl> $t = 6**64;; [0] Perl> $a = $t * 0.08972;; [0] Perl> $b = $t * 0.08973;; [0] Perl> print $b - $a;; 6.33402866630814e+044
Another problem is that 1 billion (or even 1 trillion) trials is such a minuscule sample that I'm not at all convinced that even those 5 digits are accurate. That figure is produced using Perl's built-in rand, which on my platform equates to MSC's hopelessly inadequate 15-bit linear congruential generator, with its known cyclic flaws.
I substituted Math::Random::MT and got substantially different results, but the MT, whilst a vastly better PRNG, is really very slow by comparison. Generating and testing an adaquate sample, say a quadrillion, would take a very long time also.
Luckily, salva came to the rescue with a very clever piece of C code that with luck will render an exact answer within the next 10 or so hours.
I'm also convinced that it can be done (very quickly) using purely numerical methods. Though it is considerably more complicated than I first thought. I just found a ridiculous typo(*) that had been hanging me up for two days. Maybe I'll make some progress now.
(*)I have variables $x_1, $x_2, $y_1, $y_2 to represent the values 1 and 2 to the left; and 1 & 2 above the current position. I thought they were vaguely mnemonic for X-1 etc.
Trouble is, in one place I typed $x-1 instead of $x_1 by accident, and whilst nothing appeared broken, the results were rubbish. I must have looked right past that typo a hundred times without spotting it!
In reply to Re^2: Pattern enumeration.
by BrowserUk
in thread Pattern enumeration.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |