Hi Wojciech,

Wojciech Gryc wrote:
Hi everyone,

After doing some reading and also contacting Simon Urbanek (the creator of
Rserve), he told me the problem lies in how R uses seed values for random
numbers. If I actually take the time to call set.seed() with some value and
then call rnorm() or a similar random variable, the values do become
different. I wrote a bit about it here:

http://wiki.services.openoffice.org/wiki/R_and_Calc_Documentation#Random_Numbers

My platform for development is Linux, but now that I moved to Windows XP to test the package, calling rnorm() for me on this OS does not actually yield
the same number over and over again.

I'm a bit concern about how some of the functionality seems to change as
above, but I guess that's what testing and debugging is for. :)

Thanks,
Wojciech

On 6/4/07, Eike Rathke <[EMAIL PROTECTED]> wrote:

Hi Leonard,

On Monday, 2007-06-04 11:38:11 +0200, Leonard Mada wrote:

> I believe this is more a Calc issue. IF I understad correctly, Calc
> tries to cache information and already calculated values. So, IF Calc
> encounters the same formula a 2nd time, then it possibly never runs
> the funciton again, BUT rather outputs the value from the Cache.

As Niklas already wrote last week in a reply to Wojciech, that is not
the case. If the function is called from different cells, no caching is
done by Calc. Also several calls within one cell formula are evaluated
independently. Only the formula result is cached for each cell
separately and reused if there was no need to flag the cell as dirty,
for example when cells changed that are referenced in the formula.

Wojciech, are you sure your code doesn't "cache" the R result, for
example by accessing it through a static variable before passing it to
Calc?

  Eike

Then it seems that this is broken only in Linux (I still suspect that something else is happening).

I did even further testing and I tried :
=RSIMPLENUM("rn <- function(x){z=c(0);for(i in 1:x) { z[i]=rnorm(1) }; z } ; rn(5)[[1]]")
works best

writing the same in RDump crashes Rserve:
rn <- function(x){z=c(0);for(i in 1:x) { z[i]=rnorm(1) }; z } ; rn(5)[[1]]
{
I've tried various forms, BUT non seems to work, e.g.
rn <- function(x){z=c(0);for(i in 1:x) { z[i]=rnorm(1) }; z } ; y<-rn(50)
}

On the other hand, writing once :
=RSIMPLENUM("rn <- function(x){z=c(0);for(i in 1:x) { z[i]=rnorm(1) }; z } ; rn(1)[[1]]")
and then writing:
=RSIMPLENUM("rn(1)[[1]]")
works as expected. The function is kept in memory, so one can compute multiple values for rn() and they are all different values.

Still do not know why Rdump crashes Rserve.

Hope, this will give you additional ideas how to test the code.

Sincerely,

Leonard

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to