search for: rsum

Displaying 20 results from an estimated 27 matches for "rsum".

Did you mean: csum
2019 Feb 19
4
code for sum function
...for(xi in x) s <- s + xi s } kahanSum <- function (x) { s <- 0.0 c <- 0.0 # running compensation for lost low-order bits for(xi in x) { y <- xi - c t <- s + y # low-order bits of y may be lost here c <- (t - s) - y s <- t } s } > rSum <- vapply(c(1:20,10^(2:7)), function(n) sum(rep(1/7,n)), 0) > rNaiveSum <- vapply(c(1:20,10^(2:7)), function(n) naiveSum(rep(1/7,n)), 0) > rKahanSum <- vapply(c(1:20,10^(2:7)), function(n) kahanSum(rep(1/7,n)), 0) > > table(rSum == rNaiveSum) FALSE TRUE 21 5 > table...
2007 Mar 24
1
frequency tables and sorting by rowSum
...n i for example turn: 0 1 0 0 0 1 0 1 0 1 0 0 0 1 0 1 0 0 into 0 0 1 1 1 0 0 2 0 1 0 3 My second problem is, sorting rows and columns of a matrix by the rowSums/colSums. I did it this way, but i think there should be a more efficient way: sortRowCol<-function(taus) { swaprow <- function(rsum) { taus[(rowSums(taus)==rsum),] } for( i in 1:2 ) taus<-sapply(sort(rowSums(taus)),swaprow) } thanks in advantage, Stefan Nachtnebel -- "Feel free" - 5 GB Mailbox, 50 FreeSMS/Monat ... Jetzt GMX ProMail testen: www.gmx.net/de/go/mailfooter/promail-out
2005 Jun 05
0
[PATCH] line endings fix
...W + MAX_ORDER]; -static Float_t* rout; -static unsigned int sampleWindow; /* number of samples required to reach number of milliseconds required for RMS window */ -static unsigned long totsamp; -static double lsum; -static double rsum; -static int freqindex; -static Uint32_t A [(size_t)(STEPS_per_dB * MAX_dB)]; -static Uint32_t B [(size_t)(STEPS_per_dB * MAX_dB)]; - -/* for each filter: - [0] 48 kHz, [1] 44.1 kHz, [2] 32 kHz, [3] 24 kHz, [4] 22050 Hz, [5] 16 kHz, [6] 12 kHz, [7] is 11025 Hz, [8] 8 kHz */ - -#ifd...
2005 Jun 04
2
[PATCH] line endings fix
The replay gain code has dos line endings in CVS, which causes problems for the Sun compiler, among others. Attached is a patch for the lazy, but it's probably easier to fix locally and commit. -r
2004 Apr 25
2
nonparametric multiple sample comparison
...<- aggregate(VarCat,list(LevCat=VarCat),FUN=length) RLevCat <- aggregate(Rank,list(LevCat=VarCat),FUN=sum) MLevCat <- aggregate(Rank,list(LevCat=VarCat),FUN=mean) SampleSummary <- data.frame(LevCat,RLevCat[,2],NLevCat[,2],MLevCat[,2]) names(SampleSummary)<-c("Samples","RSum","N","RMean") SampleSummary <- SampleSummary[order(SampleSummary$RMean,decreasing=T),] NCat <- length(LevCat) N <- length(dat.multcomp$VarCat) Results <- data.frame(rep(NA,6),rep(NA,6),rep(NA,6),rep(NA,6)) names(Results) <- c("Comparison","Diff...
2005 May 25
0
Error with user defined split function in rpart (PR#7895)
...parms, continuous) { print("***** START: TEMP2 *****"); n <- length(y) # For binary y, get P(Y=0)/n and P(Y=1)/n at each split temp <- cumsum(y*wt)[-n] left.wt <- cumsum(wt)[-n] right.wt <- sum(wt) - left.wt lp <- temp/left.wt rsum <- matrix(nrow=1, ncol=n-1, data=0); for (i in seq(1, n-1)) { for (j in seq(i+1, n)) { rsum[i] <- rsum[i] + y[j]; } } rp <- rsum/right.wt lprop <- 1 - lp; rprop <- rp; # Get the direction direc <- matrix(nrow=1, ncol...
2019 Feb 14
5
code for sum function
Hello, I am trying to write FORTRAN code to do the same as some R code I have. I get (small) differences when using the sum function in R. I know there are numerical routines to improve precision, but I have not been able to figure out what algorithm R is using. Does anyone know this? Or where can I find the code for the sum function? Regards, Rampal Etienne
2019 Feb 20
0
code for sum function
...gt; { > s <- 0.0 > c <- 0.0 # running compensation for lost low-order bits > for(xi in x) { > y <- xi - c > t <- s + y # low-order bits of y may be lost here > c <- (t - s) - y > s <- t > } > s > } > > > rSum <- vapply(c(1:20,10^(2:7)), function(n) sum(rep(1/7,n)), 0) > > rNaiveSum <- vapply(c(1:20,10^(2:7)), function(n) naiveSum(rep(1/7,n)), > 0) > > rKahanSum <- vapply(c(1:20,10^(2:7)), function(n) kahanSum(rep(1/7,n)), > 0) > > > > table(rSum == rNaiveSum) >...
2010 Aug 23
1
Speeding up sum and prod
...on for the improvement is that the current code (in 2.11.1 and in the development release of 2010-08-19) makes a costly call of ISNAN even when the option is na.rm=FALSE. The inner loop can also be sped up a bit in other respects. Here is the old procedure, in src/main/summary.c: static Rboolean rsum(double *x, int n, double *value, Rboolean narm) { LDOUBLE s = 0.0; int i; Rboolean updated = FALSE; for (i = 0; i < n; i++) { if (!ISNAN(x[i]) || !narm) { if(!updated) updated = TRUE; s += x[i]; } } *value = s; return(updated)...
2019 Feb 20
3
code for sum function
...find these files? Do they contain the code for the sum function? What do you mean exactly with your point on long doubles? Where can I find documentation on this? Cheers, Rampal On Mon, Feb 18, 2019, 15:38 Tomas Kalibera <tomas.kalibera at gmail.com wrote: > See do_summary() in summary.c, rsum() for doubles. R uses long double > type as accumulator on systems where available. > > Best, > Tomas > > On 2/14/19 2:08 PM, Rampal Etienne wrote: > > Hello, > > > > I am trying to write FORTRAN code to do the same as some R code I > > have. I get (small)...
2019 Feb 19
0
code for sum function
...gt; { > s <- 0.0 > c <- 0.0 # running compensation for lost low-order bits > for(xi in x) { > y <- xi - c > t <- s + y # low-order bits of y may be lost here > c <- (t - s) - y > s <- t > } > s > } > >> rSum <- vapply(c(1:20,10^(2:7)), function(n) sum(rep(1/7,n)), 0) >> rNaiveSum <- vapply(c(1:20,10^(2:7)), function(n) naiveSum(rep(1/7,n)), 0) >> rKahanSum <- vapply(c(1:20,10^(2:7)), function(n) kahanSum(rep(1/7,n)), 0) >> >> table(rSum == rNaiveSum) > > FALSE T...
2019 Feb 20
0
code for sum function
...- 0.0 # running compensation for lost low-order bits >> for(xi in x) { >> y <- xi - c >> t <- s + y # low-order bits of y may be lost here >> c <- (t - s) - y >> s <- t >> } >> s >> } >> >> > rSum <- vapply(c(1:20,10^(2:7)), function(n) sum(rep(1/7,n)), 0) >> > rNaiveSum <- vapply(c(1:20,10^(2:7)), function(n) naiveSum(rep(1/7,n)), >> 0) >> > rKahanSum <- vapply(c(1:20,10^(2:7)), function(n) kahanSum(rep(1/7,n)), >> 0) >> > >> > table(...
2004 May 27
2
block diagonal matrix function
Hello List I have just written a little function that takes two matrices as arguments and returns a large matrix that is composed of the two input matrices in upper-left position and lower-right position with a padding value everywhere else. (function definition and toy example below). I need nonsquare matrices and rowname() and colname() inherited appropriately. Two questions: (1) Is there a
2019 Feb 21
1
code for sum function
...What do you mean exactly with your point on long doubles? Where can I find > > documentation on this? > > > > Cheers, Rampal > > > > On Mon, Feb 18, 2019, 15:38 Tomas Kalibera <tomas.kalibera at gmail.com wrote: > > > >> See do_summary() in summary.c, rsum() for doubles. R uses long double > >> type as accumulator on systems where available. > >> > >> Best, > >> Tomas > >> > >> On 2/14/19 2:08 PM, Rampal Etienne wrote: > >>> Hello, > >>> > >>> I am trying to wri...
2008 Jul 23
3
sum each row and output results
Hello, I have the following data frame (DF): V5 V5.1 V5.2 V5.3 V5.4 V5.5 2 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 3 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 4 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677 -6498.7183 5 -5890.18905 -6019.84665 -6211.06545 -6198.9353 -6616.8677
2006 Jan 22
0
Rank Product
...topGene(RP.out, cutoff = 0.05, logged = TRUE, logbase = 2, g.names) Table1: Genes called significant under class1 < class2 Table2: Genes called significant under class1 > class2 $Table1 gene.index RP/Rsum FC:(class1/class2) pfp Gen n 51 15.8595 0.8204 0.0000 Gen n-1 65 18.3764 0.9582 0.0250 Gen n-2 75 18.6893 0.8916 0.0167 Gen n-3 52 19.0778 0.8928 0.0150 ……………………………………………. $Table2...
2013 Mar 20
1
double in summary.c : isum
Hi, Please consider the following : > x = as.integer(2^30-1) [1] 1073741823 > sum(c(rep(x, 10000000), rep(-x,9999999))) [1] 1073741824 Tested on 2.15.2 and a recent R-devel (r62132). I'm wondering if s in isum could be LDOUBLE instead of double, like rsum, to fix this edge case? https://svn.r-project.org/R/trunk/src/main/summary.c Thanks, Matthew
2011 Jul 15
1
Confusing inheritance problem
I have library in development with a function that works when called from the top level, but fails under R CMD check. The paricular line of failure is rsum <- rowSums(kmat>0) where kmat is a dsCMatrix object. I'm currently stumped and looking for some ideas. I've created a stripped down library "ktest" that has only 3 functions: pedigree.R to create a pedigree or pedigreeList object, kinship.R with "kinship&quot...
2013 Jun 27
3
using "rollapply" to calculate a moving sum or running sum?
#using "rollapply" to calculate a moving sum or running sum? #I am tryign to use rollapply to calcualte a moving sum? #I tried rollapply and get the error message #"Error in seq.default(start.at, NROW(data), by = by) : # wrong sign in 'by' argument" #example: mymatrix <- ( matrix(data=1:100, nrow=5, ncol=20) ) mymatrix_cumsum <- ( matrix(data=NA, nrow=5,
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
...t(typeof(z) == "double") > system.time(sum(z, na.rm=FALSE)) user system elapsed 4.49 0.00 4.51 Following the source code, I'm pretty sure the code (https://github.com/wch/r-source/blob/trunk/src/main/summary.c#L112-L128) performing the calculation is: static Rboolean rsum(double *x, R_xlen_t n, double *value, Rboolean narm) { LDOUBLE s = 0.0; Rboolean updated = FALSE; for (R_xlen_t i = 0; i < n; i++) { if (!narm || !ISNAN(x[i])) { if(!updated) updated = TRUE; s += x[i]; } } if(s > DBL_MAX) *value = R_PosInf; else if (s < -D...