search for: 1e4

Displaying 20 results from an estimated 99 matches for "1e4".

Did you mean: 14
2009 Mar 27
1
Out of memory crash on 64-bit Fedora
...I don't know if this is an R problem or a Fedora problem (I suppose the kernal should be killing R before it crashes, but shouldn't R stop before it takes all the memory?). To replicate this behavior, I can crash the system by allocating more and more memory in R: v1=matrix(nrow=1e5,ncol=1e4) v2=matrix(nrow=1e5,ncol=1e4) v3=matrix(nrow=1e5,ncol=1e4) v4=matrix(nrow=1e5,ncol=1e4) etc. until R claims all RAM and swap space, and crashes the machine. If I try this on a windows machine eventually the allocation fails with an error in R, " Error: cannot allocate vector of size XX MB&q...
2005 Aug 05
6
Computing sums of the columns of an array
Hi, I have a 5x731 array A, and I want to compute the sums of the columns. Currently I do: apply(A, 2, sum) But it turns out, this is slow: 70% of my CPU time is spent here, even though there are many complicated steps in my computation. Is there a faster way? Thanks, Martin
2009 Jan 29
1
Arima_Like() and NaN - a (possible) problem, a patch, and RFC
...-finite finite-difference value [2] I looked into the code (file src/arima.c of the stats package) and noticed that this second element is a sum of logarithmic terms, computed through the following snippet of code: gain = M[0]; for (j = 0; j < d; j++) gain += delta[j] * M[r + j]; if(gain < 1e4) { nu++; ssq += resid * resid / gain; sumlog += log(gain); } Here, sumlog is the second element of the resulting vector. However, the "if(gain < 1e4) {" check does not explicitly check against negative values of the gain variable. Indeed, whenever the gain variable assumes...
2008 Jul 08
1
split.Date
...ntially improve performance for the tapply function on class Date as well. Thanks, Robert split.Date <- function(x, f, drop=FALSE) { x <- split.default(as.integer(x), f, drop=drop) for (i in seq(along=x)) class(x[[i]]) <- "Date" x } > vals <- round(1000*rnorm(1e4)) > date <- rep(Sys.Date() + -1:1, length.out=1e4) > system.time(x1 <- split.default(date, vals)) user system elapsed 7.718 0.042 7.761 > system.time(x2 <- split.Date(date, vals)) user system elapsed 0.044 0.000 0.044 > all.equal(x1, x2) [1] TRUE Robert...
2008 Apr 10
1
ISOdate/ISOdatetime performance suggestions, other date/time questions
...applied on POSIXct? There is hardly anything simpler than on double values... Thanks in advance for your comments, Oleg It's common in finance to work with time stamps stored in a form like %Y%m%d.%H%M%OS, e.g. 20080410.140444 for now, this is what 'ts' in the example below is: ts = 1e4*trunc(rnorm(50000,2008,2)) + 1e2*trunc(runif(50000,1,12)) + trunc(runif(50000,1,28)) + 1e-2*trunc(runif(50000,1,24)) + 1e-4*trunc(runif(50000,1,60)) + 1e-6*runif(50000,1,60) posix.viaISOdate = function(x) { date = trunc(x at .Data) time = round(1e6*x at .Data%%1,2) rtime = r...
2008 Mar 14
1
smoothScatter
...trying to plot density plots using the example on: http://addictedtor.free.fr/graphiques/graphcode.php?graph=139 I used to use this function, but I cannot get any old code or even the example to work. library("geneplotter") require("RColorBrewer") x1 <- matrix(rnorm(1e4), ncol=2) x2 <- matrix(rnorm(1e4, mean=3, sd=1.5), ncol=2) x <- rbind(x1,x2) layout(matrix(1:4, ncol=2, byrow=TRUE)) op <- par(mar=rep(2,4)) smoothScatter(x, nrpoints=0) smoothScatter(x) smoothScatter(x, nrpoints=Inf, colramp=colorRampPalette(brewer.pal(9,&...
2001 Nov 02
1
Look, Watson! La.svd & ATLAS
.... R is a collaborative project with many contributors. Type `contributors()' for more information. Type `demo()' for some demos, `help()' for on-line help, or `help.start()' for a HTML browser interface to help. Type `q()' to quit R. > set.seed(1) > x <- matrix(runif(1e4), 1e2, 1e2) > invisible(La.svd(x)) # This ran fine. > x <- matrix(runif(1e5), 1e3, 1e2) > invisible(La.svd(x)) (Dr. Watson says there's an access violation.) So far La.svd is the only thing I know of that generates Dr. Watson. The version info: _...
2012 Feb 02
1
pgfSweave doesn't lazyload my objects
...something obvious. Below is my .Rnw and sessionInfo. Pointers, suggestions, etc are most welcome. %%%%%%%%%%%%%%% RNW; test_png.Rnw %%%%%%%%%%%%%%%%%%%%%% \documentclass{article} \begin{document} some bla bla text <<large-chunk-no-cache, cache=false>>= mm1 <- matrix(1:1e7, 1e3, 1e4) @ <<c2>>= print(length(mm1)) @ <<large-chunk-do-cache, cache=true>>= mm2 <- matrix(1:1e7, 1e3, 1e4) @ <<c4>>= print(length(mm2)) @ \end{document} %%%%%%%%%%%%%%%%% END RNW %%%%%%%%%%%%%%%%%% I am running the folowing R command: pgfSweave('test_pgf....
2011 Nov 04
2
Efficiency of factor objects
...ient since they use small integers. But in fact, for many (but not all) operations, R factors are considerably slower than integers, or even character strings. This appears to be because whenever a factor vector is subsetted, the entire levels vector is copied. For example: > i1 <- sample(1e4,1e6,replace=T) > c1 <- paste('x',i1) > f1 <- factor(c1) > system.time(replicate(1e4,{q1<-i1[100:200];1})) user system elapsed 0.03 0.00 0.04 > system.time(replicate(1e4,{q1<-c1[100:200];1})) user system elapsed 0.04 0.00 0.04 > system.tim...
2007 Jun 13
1
passing (or obtaining) index or element name of list to FUN in lapply()
...doesn't seem to make much of a difference (unless I have not selected a rigorous test): > N <- 10000 > y <- runif(N) ## looping through elements of y > system.time(lapply(y, + function(x) { + set.seed(222) + mean(rnorm(1e4,x,1)) + })) [1] 21.00 0.17 21.29 NA NA ## looping through indices > system.time(lapply(1:N, + function(x,y) { + set.seed(222) + mean(rnorm(1e4,y[x],1)) + },y=y)) [1] 21.09 0.14 21.26 N...
2012 Jun 22
1
Variance with confidence interval
Hi, Is there a way to calculate variance directly by specifying confidence interval using R ? I am specifically asking because I wanted to investigate how this could be useful for project schedule variance calculation. Moreover I am interested in using R for monte carlo simulation as well and any simple examples would help. I read that project schedules would benefit from this.
2004 Feb 05
0
correction to the previously asked question (about mergin g factors)
First of all, I do not understand why conversion to characters are not allowed. That's what Sundar's solution is doing implicitly (but more elegantly). Here's a test of all three. See the function definitions below. > f1 <- factor(sample(letters[1:3], 1e4, replace=TRUE)) > f2 <- factor(sample(letters[3:5], 1e4, replace=TRUE)) > f3 <- factor(sample(letters[5:7], 1e4, replace=TRUE)) > > system.time(for (i in 1:1e2) mf <- mergeFac(f1, f2, f3)) [1] 4.54 0.00 4.73 NA NA > system.time(for (i in 1:1e2) mf2 <- mergeFac2(f1, f...
2005 Jan 05
4
output from table() in matrix form
...[1,] 1 2 20 [2,] 4 1 1 Is there a better way? It seems inelegant to coerce a character vector back to integers, but OTOH it's wasteful to have 20 bins when I only need 3. My real application would have maybe a dozen distinct (prime) integers in the range 2 up to about 1e4. -- Robin Hankin Uncertainty Analyst Southampton Oceanography Centre European Way, Southampton SO14 3ZH, UK tel 023-8059-7743
2016 Oct 12
4
[test-suite] making polybench/symm succeed with "-Ofast" and "-ffp-contract=on"
...ests from "-O0 -ffp-contract=off" also matches the reference output. The following 2 tests still require increased FP_ABSTOLERANCE to pass compare between "-O3", "-O3 -ffp-contract=on" vs. "-O0 -ffp-contract=off" polybench/medley/reg_detect, FP_ABSTOLERANCE=1e4 polybench/stencils/adi, FP_ABSTOLERANCE=1e4 The reference output of these two is also not matching when compiled at "-O3" or "-O3 -ffp-contract=on". When configuring the test-suite without specifying CFLAGS, Polybench is compiled at no optimization level.
2014 Sep 07
2
normalizePath is sometimes very slow for nonexistent UNC paths
...en able to generate slow runs on my Linux machine, though I've had problems with slow running examples submitted to CRAN that I suspect may be caused by this. library(microbenchmark) (timings <- microbenchmark( normalizePath("\\\\some/network/drive", mustWork = FALSE), times = 1e4, unit = "s" )) boxplot(timings) Please can a few people run this code and see if they can reproduce the issue. It isn't clear to me whether this is a bug in R or an underlying OS or network problem. -- Regards, Richie
2009 Nov 27
2
Symmetric Matrix classes
...ces using Matrix classes. dsyMatrix seems like the right one, but I want to specify just the upper/lower triangle and diagonal and not have to instantiate a huge n^2 vector just for the sake of having half of it ignored: Dumb example: M <- new("dsyMatrix", uplo="U", x=rnorm(1e4), Dim=as.integer(c(100, 100))) diag(M) <- 1 This doesn't work: M <- new("dsyMatrix", uplo="U", x=0, Dim=as.integer(c(100, 100))) Error in validObject(.Object) : invalid class "dsyMatrix" object: length of x slot != prod(Dim) Is there an easier way of doin...
2005 Oct 20
5
spliting an integer
Hi there, From the vector X of integers, X = c(11999, 122000, 81997) I would like to make these two vectors: Z= c(1999, 2000, 1997) Y =c(1 , 12 , 8) That is, each entry of vector Z receives the four last digits of each entry of X, and Y receives "the rest". Any suggestions? Thanks in advance, Dimitri [[alternative HTML version deleted]]
2001 Nov 06
1
R-devel & ATLAS generates Dr. Watson on NT (was RE: Look, Wa tson! La.svd & ATLAS)
...y contributors. > Type `contributors()' for more information. > > Type `demo()' for some demos, `help()' for on-line help, or > `help.start()' for a HTML browser interface to help. > Type `q()' to quit R. > > > set.seed(1) > > x <- matrix(runif(1e4), 1e2, 1e2) > > invisible(La.svd(x)) # This ran fine. > > x <- matrix(runif(1e5), 1e3, 1e2) > > invisible(La.svd(x)) > > (Dr. Watson says there's an access violation.) I was able to run those examples without ill effects on an R-1.4.0 (develo...
2002 Jun 27
2
Fastest way to find the last index k such that x[k] < y in a sorted vector x?
Hi, I am trying to find the fastest way to "find the last index k such that x[k] < y in a *sorted* vector x" These are my two alternatives: x <- sort(rnorm(1e4)) y <- 0.2 # Alt 1 k <- max(1, sum(x < y)) # Alt 2 "divide and conquer" lastIndexLessThan <- function(x, y) { k0 <- 1; k1 <- length(x) while ((dk <- (k1 - k0)) > 1) { k <- k0 + dk %/% 2 if (x[k] < y) k0 <- k else k1 <- k...
2011 Aug 09
2
S4 classes, some help with the basics
...ithout knowing the name a priori? E.g., let's say I use the "pcaMethods" library to create a "pcaRes" object. How can I call parts of that object without using the specific names of the object in the call? example code: library(pcaMethods) myMatrix <- matrix(runif(1e4), ncol=100) ## silly, but sufficient for example myPCA <- pca(myMatrix) ## creates a "pcaRes" S4 class for (i in slotNames(myPCA) ) { summary(myPCA@i) ### I know this doesn't work, but this is the question... what grammar could I use? } ################ I would like to b...