Yes, the examples I gave require J7.01 to work.


On Sat, Oct 29, 2011 at 9:14 AM, Bo Jacoby <[email protected]> wrote:
> In J602  I get
>    ^o.j.-:i. 3 4
>              1 6.12323e_17j1 _1j1.22465e_16 _1.83697e_16j_1
> 1j_2.44929e_16 3.06162e_16j1 _1j3.67394e_16 _4.28626e_16j_1
> 1j_4.89859e_16 5.51091e_16j1 _1j6.12323e_16 _2.44991e_15j_1
>
>
>
>
>
>>________________________________
>>Fra: Roger Hui <[email protected]>
>>Til: Programming forum <[email protected]>
>>Sendt: 18:07 lørdag den 29. oktober 2011
>>Emne: Re: [Jprogramming] 32- & 64-bit PRNGs
>>
>>Ah yes, _1j1.22461e_16.  I can't do much about the 1.22461e_16
>>(welcome to the ugly realities of floating point arithmetic), but I
>>can do this:
>>
>>   ^@o. j. 0.5 * i. 3 4
>>1 0j1 _1 0j_1
>>1 0j1 _1 0j_1
>>1 0j1 _1 0j_1
>>
>>   ^@o. j. 2e9 + 0.5 * i. 3 4
>>1 0j1 _1 0j_1
>>1 0j1 _1 0j_1
>>1 0j1 _1 0j_1
>>
>>(In J7.01.)
>>
>>
>>
>>On Sat, Oct 29, 2011 at 8:48 AM, Linda Alvord <[email protected]> wrote:
>>> Here's what I was thinking:
>>>
>>>
>>>   -^1p1*0j1
>>> 1j_1.22465e_16
>>>
>>> I forgot that "i" is 0j1  (quite a coincidence?) in J
>>>
>>> Also, it was always more satisfying to me that the result is 1.
>>>
>>> However, we do agree.
>>>
>>>   -^1p1*0j1
>>> 1j_1.22465e_16
>>>
>>>
>>> -----Original Message-----
>>> From: [email protected] 
>>> [mailto:[email protected]] On Behalf Of Roger Hui
>>> Sent: Friday, October 28, 2011 11:48 AM
>>> To: Programming forum
>>> Subject: Re: [Jprogramming] 32- & 64-bit PRNGs
>>>
>>> Isn't that just saying that (^1)^0 is 1?  On the other hand:
>>>
>>>   _1 = ^ 1p1 * 0j1
>>> 1
>>>
>>> http://www.jsoftware.com/jwiki/Essays/Euler%27s%20Identity
>>>
>>>
>>>
>>> On Fri, Oct 28, 2011 at 12:48 AM, Linda Alvord <[email protected]> 
>>> wrote:
>>>> Ken might have answered that God must be an awesome mathematician, since 
>>>> he might have understood God better than most.
>>>>
>>>>   (^1)^-o.i.1
>>>> 1
>>>>
>>>>
>>>> -----Original Message-----
>>>> From: [email protected] 
>>>> [mailto:[email protected]] On Behalf Of Ian Clark
>>>> Sent: Thursday, October 27, 2011 2:38 PM
>>>> To: Programming forum
>>>> Subject: Re: [Jprogramming] 32- & 64-bit PRNGs
>>>>
>>>> I wonder if Carl Sagan, like Feynman, wasn't having joke after joke at
>>>> his audience's expense? (APWJ p 136, see also end of:
>>>> http://www.jsoftware.com/jwiki/Doc/Articles/Play151)
>>>>
>>>> The probability of any given finite pattern turning up in the first N
>>>> digits of a random sequence tends to 1 as N tends to infinity. The
>>>> aforementioned site estimates the odds for various values of N:
>>>> http://www.angio.net/pi/piquery#likely
>>>>
>>>> Sagan didn't say how many digits Ellie had to search (N) for her
>>>> (initially undefined) pattern. Was N sufficiently low to reject the
>>>> null hypothesis? The implication is: it wasn't. Nor is pi a random
>>>> series (it's pseudo-random). And when you're reading the Mind of God
>>>> -- does the null hypothesis have any cause to exist? -- viz is there
>>>> any merit in *guessing* the Mind of God?
>>>>
>>>> Nor is it the first time in the novel Ellie is the victim of illusion
>>>> (the alien deludes her he's her father... and yet she knows that).
>>>>
>>>> The whole novel is shot through with existential jokes, playing-off
>>>> science against sentiment. Once I spotted that I was ready to forgive
>>>> Sagan any amount of Slartibartfastian pseudo-engineering of pi.
>>>>
>>>>
>>>> On Thu, Oct 27, 2011 at 1:51 PM, Roger Hui <[email protected]> 
>>>> wrote:
>>>>>> For initial experiments, there's already a site which stores the first
>>>>>> 200M digits of pi, for hobbyists wanting to do Carl Sagan
>>>>>> "Contact"-type research:
>>>>>
>>>>> When I first read that in "Contact" years ago it knocked down by
>>>>> several notches my respect for the novel.  Even the Almighty doesn't
>>>>> have any choice about the digits of π, right?  What's He/She going to
>>>>> do about the various power series, f'instance?
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Oct 27, 2011 at 5:26 AM, Ian Clark <[email protected]> wrote:
>>>>>> Being old enough to have learned my electronics before the digital
>>>>>> age, I wonder if it isn't time to reconsider shot noise as a source of
>>>>>> random numbers. It has a forensic advantage in lottery draws, and
>>>>>> monte-carlo simulations of fraught political topics like climate
>>>>>> change, by taking the "pseudo" out of "pseudo-random".
>>>>>>
>>>>>> For years the UK gov ran a device called ERNIE
>>>>>>  http://en.wikipedia.org/wiki/ERNIE#ERNIE
>>>>>> to pick premium bonds (a savings scheme where the interest payable was
>>>>>> put in a monthly draw).
>>>>>>
>>>>>> A device to generate binary digits from electronic noise would be so
>>>>>> simple it ought to be fitted as standard to today's desktop computers.
>>>>>> Failing that, if I had a serious need for true random numbers I'd
>>>>>> experiment with an open microphone line using Audacity to save the
>>>>>> number stream as a WAV.
>>>>>>
>>>>>> Need a reproducible number stream? With the amount of free storage
>>>>>> space in the "cloud" (I currently have access to around 2 GB and I
>>>>>> don't remember asking for it) why not just store it? I also have a 1TB
>>>>>> disk drive, mostly lying empty.
>>>>>>
>>>>>> For initial experiments, there's already a site which stores the first
>>>>>> 200M digits of pi, for hobbyists wanting to do Carl Sagan
>>>>>> "Contact"-type research:
>>>>>> http://www.angio.net/pi/piquery
>>>>>> Aside: ought the hunt for meaningful sequences in pi to be called 
>>>>>> perimancy? :-)
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Fri, Oct 14, 2011 at 8:30 PM, Zsbán Ambrus <[email protected]> wrote:
>>>>>>> On Fri, Oct 14, 2011 at 2:33 PM, Zsbán Ambrus <[email protected]> 
>>>>>>> wrote:
>>>>>>>> On Fri, Oct 14, 2011 at 1:08 PM, Ewart Shaw <[email protected]> 
>>>>>>>> wrote:
>>>>>>>>> I want to generate pseudorandom sequences that are the same for 32- & 
>>>>>>>>> 64-bit J.
>>>>>>>>
>>>>>>>> Have you tried the other random generators the (9!:43) foreign makes
>>>>>>>> available?  I'd guess some of them are the same for 32 and 64 bit J.
>>>>>>>
>>>>>>> Hmm, from a quick test, it seems Roger is right: none of the built in
>>>>>>> generators give the same results on the 32-bit and 64-bit J.
>>>>>>>
>>>>>>> Let's use the random generation functions from GSL (
>>>>>>> http://www.gnu.org/software/gsl/ ) then.  This example implements
>>>>>>> roll, but not deal.
>>>>>>>
>>>>>>>
>>>>>>> $ cat rngwrap.c
>>>>>>> #include <gsl/gsl_rng.h>
>>>>>>>
>>>>>>> /*
>>>>>>> Allocate a new random generator of the Mersenne Twister algorithm
>>>>>>> and initialize it with the default seed.
>>>>>>> */
>>>>>>> gsl_rng *
>>>>>>> wrap_newrng(void) {
>>>>>>>        gsl_rng *g = gsl_rng_alloc(gsl_rng_mt19937);
>>>>>>>        return g;
>>>>>>> }
>>>>>>>
>>>>>>> $ cat rngwrap.ijs
>>>>>>> NB. random generator functions from GSL
>>>>>>> rngobj=: <'./rngwrap.so wrap_newrng > x'15!:0$0
>>>>>>> rollint=: './rngwrap.so gsl_rng_uniform_int > x *c x'15!:0 rngobj;]
>>>>>>> rollflo=: './rngwrap.so gsl_rng_uniform_pos > d *c'15!:0 (,<rngobj)"_
>>>>>>> roll=: rollflo`rollint`[:@.*"0 :[:
>>>>>>>
>>>>>>> $ gcc -Wall -O -fpic -lm -lgslcblas -lgsl -shared -o rngwrap.so 
>>>>>>> rngwrap.c
>>>>>>> $ jconsole rngwrap.ijs
>>>>>>>   roll (10$1e4),5$0
>>>>>>> 9997 1629 2826 9472 2316 4849 9574 7443 5400 7399 0.759944 0.658637
>>>>>>> 0.315638 0.804403 0.519672
>>>>> ----------------------------------------------------------------------
>>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>>
>>>> ----------------------------------------------------------------------
>>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>----------------------------------------------------------------------
>>For information about J forums see http://www.jsoftware.com/forums.htm
>>
>>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to