Dear Dennis and Steve,
Am Sonntag, den 31.07.2011, 23:32 -0400 schrieb Steve Lianoglou:
[…]
How about trying to write the of this `f4` function below using the
rcpp/inline combo. The C/C++ you will need to write looks to be quite
trivial, let's change f4 to accept an x argument as a vector:
Am Sonntag, den 31.07.2011, 23:32 -0500 schrieb R. Michael Weylandt :
Glad to help -- I haven't taken a look at Dennis' solution (which may be far
better than mine), but if you do want to keep going down the path outlined
below you might consider the following:
I will try Dennis’ solution
I've only got a 20 minute layover, but three quick remarks:
1) Do a sanity check on your data size: if you want a million walks of a
thousand steps, that already gets you to a billion integers to store--even at a
very low bound of one byte each, thats already 1GB for the data and you still
Am Montag, den 01.08.2011, 12:43 -0400 schrieb R. Michael Weylandt :
I've only got a 20 minute layover, but three quick remarks:
1) Do a sanity check on your data size: if you want a million walks of
a thousand steps, that already gets you to a billion integers to
store--even at a very low
Am Mittwoch, den 27.07.2011, 19:59 -0400 schrieb R. Michael Weylandt :
Some more skilled folks can help with the curve fitting, but the general
answer is yes -- R will handle this quite ably.
Great to read that.
Consider the following code:
--
n = 1e5
Hi:
See if this works for you:
f4 - function()
{
x - sample(c(-1L,1L), 1)
if (x = 0 ) {return(1)} else {
csum - x
len - 1
while(csum 0) {
csum - csum + sample(c(-1, 1), 1)
len - len + 1
Hi,
I haven't been following this thread very closely, but I'm getting the
impression that the inner loop that's killing you folks here looks
quite simple (assuming it is the one provided below).
How about trying to write the of this `f4` function below using the
rcpp/inline combo. The C/C++ you
Hi Steve:
Very, very nice. Thanks for the useful Rcpp script. I'm not surprised
that a C++ version blows my humble little R function out of the water
:) I noticed that the R function ran a lot more slowly when the
sojourns were very long. It suggests that algorithms that entail
conditional
Glad to help -- I haven't taken a look at Dennis' solution (which may be far
better than mine), but if you do want to keep going down the path outlined
below you might consider the following:
Instead of throwing away a simulation if something starts negative, why not
just multiply the entire
Dear R folks,
I need to simulate first passage times for iterated partial sums. The
related papers are for example [1][2].
As a start I want to simulate how long a simple random walk stays
negative, which should result that it behaves like n^(-½). My code looks
like this.
8
Dear R folks,
Am Donnerstag, den 28.07.2011, 01:36 +0200 schrieb Paul Menzel:
I need to simulate first passage times for iterated partial sums. The
related papers are for example [1][2].
As a start I want to simulate how long a simple random walk stays
negative, which should result that
.
From: paulepan...@users.sourceforge.net
To: r-help@r-project.org
Date: Thu, 28 Jul 2011 02:00:13 +0200
Subject: Re: [R] Is R the right choice for simulating first passage times of
random walks?
Dear R folks,
Am Donnerstag, den 28.07.2011, 01:36 +0200 schrieb Paul Menzel:
I need
, July 27, 2011 4:36 PM
To: r-help@r-project.org
Subject: [R] Is R the right choice for simulating first passage times of
random walks?
Dear R folks,
I need to simulate first passage times for iterated partial sums. The
related papers are for example [1][2].
As a start I want to simulate
Some more skilled folks can help with the curve fitting, but the general
answer is yes -- R will handle this quite ably.
Consider the following code:
--
n = 1e5
length = 1e5
R = matrix(sample(c(-1,1),length*n,replace=T),nrow=n)
R = apply(R,1,cumsum) ## this
14 matches
Mail list logo