Rowlingson
Subject: Re: [R] dist like function but where you can configure the method
Ouch,
First : my question was not how to implement dist but if there is a more
generic dist function than stats:dist.
Secondly: ks.test is ment as a placeholder (see the comment in the code I did
send) for any
If the apply() call is not empty, its contents must of course be
interpreted. That's where the time goes.
>system.time(for(i in 1:1e6)rnorm(1))
user system elapsed
5.250.005.29
> system.time(lapply(1:1e6,rnorm,n=1))
user system elapsed
9.640.019.72
> system.time(vap
>> system.time(apply(t(1:(n*n)),1,myfunc))
>User System verstrichen
>0.190.000.19
That calls 'myfunc' exactly once:
> system.time(apply(t(1:(3*3)), 1, print))
[1] 1 2 3 4 5 6 7 8 9
user system elapsed
0 0 0
Bill Dunlap
TIBCO Software
wd
Ouch,
First : my question was not how to implement dist but if there is a
more generic dist function than stats:dist.
Secondly: ks.test is ment as a placeholder (see the comment in the
code I did send) for any other function taking two vector arguments.
Third: I do subscribe to the idea that a f
Hello,
The compiler package is good at speeding up for loops but in this case
the gain is neglectable. The ks test is the real time problem.
library(compiler)
f1 <- function(n){
for(i in 1:100){
for(i in 1:100){
ks.test(runif(100),runif(100))
I did not regard the loops as the overhead but a part of the process. Overhead
is setting attributes. The loop is not so very expensive compared to ks.test().
You can always replace the loop with an apply on the vector of indices, but
about the only way to speed up calculations is to use paralle
Yes, ... and further
apply-type functions still have to loop at the interpreter level, and
generally take about the same time as their translation to for loops
(with suitable caveats for this kind of vague assertion). Their chief
advantage is readability and adherence to R's functional paradigm
(a
On Fri, May 16, 2014 at 4:46 PM, Witold E Wolski wrote:
> Dear Jari,
>
> Thanks for your reply...
>
> The overhead would be
> 2 for loops
> for(i in 1:dim(x)[2])
> for(j in i:dim(x)[2])
>
> isn't it? Or are you seeing a different way to implement it?
>
> A for loop is pretty expensive in R. Theref
Dear Jari,
Thanks for your reply...
The overhead would be
2 for loops
for(i in 1:dim(x)[2])
for(j in i:dim(x)[2])
isn't it? Or are you seeing a different way to implement it?
A for loop is pretty expensive in R. Therefore I am looking for an
implementation similar to apply or lapply were the it
Witold E Wolski gmail.com> writes:
>
> Looking for an fast dist implementation
> where I could pass my own dist function to the "method" parameter
>
> i.e.
>
> mydistfun = function(x,y){
> return(ks.test(x,y)$p.value) #some mystique implementation
> }
>
> wow = dist(data,method=mydistfun)
Looking for an fast dist implementation
where I could pass my own dist function to the "method" parameter
i.e.
mydistfun = function(x,y){
return(ks.test(x,y)$p.value) #some mystique implementation
}
wow = dist(data,method=mydistfun)
thanks
--
Witold Eryk Wolski
__
11 matches
Mail list logo