Hi there
I'm loking for a time-measurement to measure time-differences in
milliseconds.
On my search, I only found the following:
- package "base": Sys.time()
-> only second-accuracy
- package "R.utils": System$currentTimeMillis()
-> returns integer of milliseconds, but accuracy is only whole
seconds too.
At the moment I run every bit of code to measure 1000-times to be able
to calculate time in milliseconds... ;-)
Has anyone a method to get milliseconds?
Thanks for any help.
Be aware that the measurement will itself take more than a millisecond from an interpreted language like R. Please see the help page for Sys.time, and its suggestion of proc.time. for(i in 1:100) print(proc.time()[3]) suggests this takes 3ms on my box. On Mon, 7 Nov 2005, Sydler, Dominik wrote:> Hi there > > I'm loking for a time-measurement to measure time-differences in > milliseconds. > On my search, I only found the following: > - package "base": Sys.time() > -> only second-accuracy > - package "R.utils": System$currentTimeMillis() > -> returns integer of milliseconds, but accuracy is only whole > seconds too. > At the moment I run every bit of code to measure 1000-times to be able > to calculate time in milliseconds... ;-) > > Has anyone a method to get milliseconds? > > Thanks for any help. > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html >-- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
Dear R-help,
I would like to accelerate my R computation by using parallel OpenMP compilers
(e.g from Pathscale) on a 2-processor AMD server and I would like to know
whether R is a tread safe library. The main kernel of the OpenMP
parallelization is a C SEXP function that performs the computational routine in
parallel with:
*******************
SEXP example(SEXP list, SEXP expr, SEXP rho)
{
R_len_t i, n = length(list);
SEXP ans, alocal;
omp_lock_t lck;
PROTECT(ans = allocVector(VECSXP, n));
ans = allocVector(VECSXP, n);
omp_init_lock(&lck);
#pragma omp parallel for default(none) private(i, alocal) shared(list,
lck,rho, ans, n, expr)
for(i = 0; i < n; i++) {
omp_set_lock(&lck);
PROTECT(alocal = allocVector(VECSXP, 1));
alocal = allocVector(VECSXP, 1);
defineVar(install("x"), VECTOR_ELT(list, i), rho);
omp_unset_lock(&lck);
/* do computational kernel in parallel */
alocal = eval(expr, rho);
omp_set_lock(&lck);
SET_VECTOR_ELT(ans, i, alocal);
UNPROTECT(1);
omp_unset_lock(&lck);
}
setAttrib(ans, R_NamesSymbol, getAttrib(list, R_NamesSymbol));
UNPROTECT(1);
return(ans);
}
***********
The code works fine using one thread and breaks currently down with 2 threads.
I am using a recent R distribution and the complete R code is compile with
"-openmp" and the Pathscale compiler suite.
Thanks in advance,
Olaf
Thanks a lot, that works fine!
Strange that I didn't find this function in the help...
Bye
Dominic
-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk]
Sent: Montag, 7. November 2005 18:27
To: Sydler, Dominik
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] Time-measurement in milliseconds
Be aware that the measurement will itself take more than a millisecond
from an interpreted language like R.
Please see the help page for Sys.time, and its suggestion of proc.time.
for(i in 1:100) print(proc.time()[3]) suggests this takes 3ms on my box.
On Mon, 7 Nov 2005, Sydler, Dominik wrote:
> Hi there
>
> I'm loking for a time-measurement to measure time-differences in
> milliseconds.
> On my search, I only found the following:
> - package "base": Sys.time()
> -> only second-accuracy
> - package "R.utils": System$currentTimeMillis()
> -> returns integer of milliseconds, but accuracy is only whole
> seconds too.
> At the moment I run every bit of code to measure 1000-times to be able
> to calculate time in milliseconds... ;-)
>
> Has anyone a method to get milliseconds?
>
> Thanks for any help.
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595
huan.huang@uk.bnpparibas.com
2005-Nov-09 10:39 UTC
[R] moc function, normal distribution peak capture
Hi
With moc function (in moc library), I try to apply a mixture of 2 normal
distribution for univariate data which has 2 peaks,
however I found it came down to 1 normal distribution (weights became 1 and
0) and could not capture the 2nd peaks in many cases.
I set the first mode and second mode as initial values of mean of normal
distribution, and set an appropriate sd as initial values of sd of normal
distribution.
Has anyone experienced this problem? If anyone could let me know how to
avoid this problem, it would be appreciated.
Thanks
Huan
This message and any attachments (the "message") is\
intende...{{dropped}}