Stefan Evert wrote:
>
>> hmm, would you be saying that r's vectorised performance is overhyped?
>> or is it just that non-vectorised code in r is slow?
>
> What I meant, I guess, was (apart from a little bit of trolling) that
> I'd had misconceptions about the speed differences between loops and
>
I ran into a similar issue with a simple benchmark the other day,
where a plain loop in Lua was faster than vectorised code in R ...
hmm, would you be saying that r's vectorised performance is overhyped?
or is it just that non-vectorised code in r is slow?
What I meant, I guess, was (apar
Stefan Evert wrote:
> A couple of remarks on vQ's naive benchmark:
>
>> f.rep = function(n, m) replicate(n, rnorm(m))
>
> I suppose you meant
>
> f.rep = function(n, m) replicate(n, mean(rnorm(m)))
>
> which doesn't make a substantial speed difference, though.
indeed, thanks; i've already pos
Patrick Burns wrote:
> Wacek Kusnierczyk wrote:
>> Patrick Burns wrote:
>>
>>> If the goal is to "look" professional, then
>>> 'replicate' probably suits. If the goal is to
>>> compute as fast as possible, then that isn't
>>> the case because 'replicate' is really a 'for'
>>> loop in disguise an
A couple of remarks on vQ's naive benchmark:
f.rep = function(n, m) replicate(n, rnorm(m))
I suppose you meant
f.rep = function(n, m) replicate(n, mean(rnorm(m)))
which doesn't make a substantial speed difference, though.
f.pat = function(n, m) colMeans(array(rnorm(n*m), c(n, m)))
Wacek Kusnierczyk wrote:
Patrick Burns wrote:
If the goal is to "look" professional, then
'replicate' probably suits. If the goal is to
compute as fast as possible, then that isn't
the case because 'replicate' is really a 'for'
loop in disguise and there are other ways.
Here's one other way
Patrick Burns wrote:
> If the goal is to "look" professional, then
> 'replicate' probably suits. If the goal is to
> compute as fast as possible, then that isn't
> the case because 'replicate' is really a 'for'
> loop in disguise and there are other ways.
>
> Here's one other way:
>
> function (si
On Mon, Feb 16, 2009 at 12:59 PM, megh wrote:
>
> Hi, I am trying to create a vector of length 10 (say), wherein each element
> will be average of random sample of size 100, from a distribution, say
> Normal. Can anyone please tell me without creating a "for" loop, how I can
> do that?
>
> Regards
If the goal is to "look" professional, then
'replicate' probably suits. If the goal is to
compute as fast as possible, then that isn't
the case because 'replicate' is really a 'for'
loop in disguise and there are other ways.
Here's one other way:
function (size, replicates, distfun, ...)
{
megh wrote:
No, it is not homework. I obviously
For some value of "obvious" as you has not given a single line of code
as the posting guide suggests.
You probably want:
replicate(10, mean(rnorm(100)))
Uwe Ligges
could do that using a for-loop, and that
I already did. However I though
No, it is not homework. I obviously could do that using a for-loop, and that
I already did. However I thought whether there could be a better approach as
it was looking very messy and unprofessional.
Uwe Ligges-3 wrote:
>
>
>
> megh wrote:
>> Hi, I am trying to create a vector of length 10 (
megh wrote:
Hi, I am trying to create a vector of length 10 (say), wherein each element
will be average of random sample of size 100, from a distribution, say
Normal. Can anyone please tell me without creating a "for" loop, how I can
do that?
Homework? Then please ask you course material or
Try this:
replicate(10, mean(rnorm(100)))
On Mon, Feb 16, 2009 at 8:59 AM, megh wrote:
>
> Hi, I am trying to create a vector of length 10 (say), wherein each element
> will be average of random sample of size 100, from a distribution, say
> Normal. Can anyone please tell me without creating a
13 matches
Mail list logo