Displaying 20 results from an estimated 63 matches for "sum2".
Did you mean:
sum
2007 Sep 01
2
Comparing "transform" to "with"
...help files or books. So I created a simplified version of what I'm
doing:
rm( list=ls() )
x1<-c(1,3,3)
x2<-c(3,2,1)
x3<-c(2,5,2)
x4<-c(5,6,9)
myDF<-data.frame(x1,x2,x3,x4)
rm(x1,x2,x3,x4)
ls()
myDF
This creates two new variables just fine"
transform(myDF,
sum1=x1+x2,
sum2=x3+x4
)
This next code does not see sum1, so it appears that "transform" cannot
see the variables that it creates. Would I need to transform new
variables in a second pass?
transform(myDF,
sum1=x1+x2,
sum2=x3+x4,
total=sum1+sum2
)
Next I'm trying the same thing using "wi...
2008 Apr 22
4
how to convert non numeric data into numeric?
I am having the following error in my function
function(theta,reqdIRR)
{
theta1<-theta[1]
theta2<-theta[2]
n<-length(reqdIRR)
constant<- n*(theta1+theta2)
sum1<-lapply(reqdIRR*exp(theta1),FUN = sum)
sum2<-lapply(exp(theta2 - reqdIRR*exp(theta1)),FUN = sum)
sum = sum1 + sum2
log.fcn = constant - as.numeric(sum)
result = - log.fcn
return(result)
}
*error : neg.log.gumbel(1,reqdIRR)
Error in sum1 + sum2 : non-numeric argument to binary operator
>
how can i rectify the error?Its really urgent....
2007 Feb 01
3
Help with efficient double sum of max (X_i, Y_i) (X & Y vectors)
...test statistic
which involves double sums of max(X_i,Y_j) where X and Y are vectors of
differing length.
I am currently using ifelse pointwise in a vector, but have a nagging
suspicion that there is a more efficient way to do this. Basically, I
require three sums:
sum1: \sum_i\sum_j max(X_i,X_j)
sum2: \sum_i\sum_j max(Y_i,Y_j)
sum3: \sum_i\sum_j max(X_i,Y_j)
Here is my current implementation - any pointers to more efficient
computation greatly appreciated.
nx <- length(x)
ny <- length(y)
sum1 <- 0
sum3 <- 0
for(i in 1:nx) {
sum1 <- sum1 + sum(ifelse(x[i]>...
2007 Apr 03
1
Speex ARM4 patch
The attached patch eliminates some warnings while compiling for ARM4
targets. It also simplifies the asm constraints a bit. Now we can use
the ARM4 optimisations when compiling for PortalPlayer targets in Rockbox.
Cheers,
Dan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: speex_arm4.patch
Type: text/x-diff
Size: 1550 bytes
Desc: not available
Url :
2003 Mar 23
1
[RFC] dynamic checksum size
...dating that transmission
in the new (read|write)_sum_head functions. A added bonus
is that write_sum_head replaces the send_null_sums function.
The Adleresque checksum1 is in no way affected.
The varsumlen patch builds on that groundwork by
implementing a simple heuristic to generate the per-file
sum2 lengths. It remains two bytes until the file is 8193
blocks at which it increments and continues incrementing
each time the block count quadruples. This builds on the
dynamic block size code (which is consolidated as well) so
that the point where we go to a 3 byte sum2 is approximately
125MB. Sp...
2008 Nov 26
1
SSE2 code won't compile in VC
...m, (__m128d) _mm_movehl_ps((__m128) sum, (__m128)
sum));
+ sum = _mm_add_sd(sum, _mm_unpackhi_pd(sum, sum));
_mm_store_sd(&ret, sum);
return ret;
}
@@ -120,7 +120,7 @@ static inline double
interpolate_product_double(const float *a, const float *b,
sum1 = _mm_mul_pd(f1, sum1);
sum2 = _mm_mul_pd(f2, sum2);
sum = _mm_add_pd(sum1, sum2);
- sum = _mm_add_sd(sum, (__m128d) _mm_movehl_ps((__m128) sum, (__m128)
sum));
+ sum = _mm_add_sd(sum, _mm_unpackhi_pd(sum, sum));
_mm_store_sd(&ret, sum);
return ret;
}
2015 Jun 01
2
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
...ple, but the above benchmarking
disagree. It looks like there is a big overhead keeping track of the
sum `s` being NA, which is supported by the fact that summing over 'z'
is costs half of 'y'.
Now, I *cannot* reproduce the above using the following 'inline' example:
> sum2 <- inline::cfunction(sig=c(x="double", narm="logical"), body='
double *x_ = REAL(x);
int narm_ = asLogical(narm);
int n = length(x);
double sum = 0;
for (R_xlen_t i = 0; i < n; i++) {
if (!narm_ || !ISNAN(x_[i])) sum += x_[i];
}
return ScalarReal(sum);
')...
2003 Mar 30
1
[RFC][patch] dynamic rolling block and sum sizes II
...er versions: the onus is on
@@ -406,7 +406,8 @@
OFF_T flength; /**< total file length */
size_t count; /**< how many chunks */
size_t remainder; /**< flength % block_length */
- size_t n; /**< block_length */
+ size_t blength; /**< block_length */
+ size_t s2length; /**< sum2_length */
struct sum_buf *sums; /**< points to info for each chunk */
};
--- proto.h Sat Mar 29 12:18:02 2003
+++ proto.h Sat Mar 29 12:15:38 2003
@@ -91,6 +91,7 @@
struct file_list *flist_new(void);
void flist_free(struct file_list *flist);
char *f_name(struct file_struct *f);
+void w...
2018 Jul 10
9
[PATCH 0/7] PowerPC64 performance improvements
The following series adds initial vector support for PowerPC64.
On POWER9, flac --best is about 3.3x faster.
Amitay Isaacs (2):
Add m4 macro to check for C __attribute__ features
Check if compiler supports target attribute on ppc64
Anton Blanchard (5):
configure.ac: Remove SPE detection code
configure.ac: Add VSX enable/disable
configure.ac: Fix FLAC__CPU_PPC on little endian, and add
2018 Jan 25
2
sum() returns NA on a long *logical* vector when nb of TRUE values exceeds 2^31
Just following up on this old thread since matrixStats 0.53.0 is now
out, which supports this use case:
> x <- rep(TRUE, times = 2^31)
> y <- sum(x)
> y
[1] NA
Warning message:
In sum(x) : integer overflow - use sum(as.numeric(.))
> y <- matrixStats::sum2(x, mode = "double")
> y
[1] 2147483648
> str(y)
num 2.15e+09
No coercion is taking place, so the memory overhead is zero:
> profmem::profmem(y <- matrixStats::sum2(x, mode = "double"))
Rprofmem memory profiling of:
y <- matrixStats::sum2(x, mode = "double&...
2013 Mar 25
2
Faster way of summing values up based on expand.grid
...ar2 == mycombos$Var4),]
mycombos<-mycombos[!(mycombos$Var3 == mycombos$Var4),]
dim(mycombos)
# I want to write sums of elements from values1, values2, and values 3
whose numbers are contained in each column of mycombos. Here is how I am
going it now - using a loop:
mycombos$sum1<-NA
mycombos$sum2<-NA
mycombos$sum3<-NA
for(i in 1:nrow(mycombos)){
mycombos$sum1[i]<-values1[[mycombos[i,"Var1"]]] +
values1[[mycombos[i,"Var2"]]] + values1[[mycombos[i,"Var3"]]] +
values1[[mycombos[i,"Var4"]]]
mycombos$sum2[i]<-values2[[mycombos[i,"Var1&...
2009 Oct 26
1
[PATCH] Fix miscompile of SSE resampler
...int len, const spx_uint32_t oversample, float *frac) {
+static inline void interpolate_product_double(double *ret, const float *a, const float *b, unsigned int len, const spx_uint32_t oversample, float *frac) {
int i;
- double ret;
__m128d sum;
__m128d sum1 = _mm_setzero_pd();
__m128d sum2 = _mm_setzero_pd();
@@ -121,8 +114,7 @@ static inline double interpolate_product_double(const float *a, const float *b,
sum2 = _mm_mul_pd(f2, sum2);
sum = _mm_add_pd(sum1, sum2);
sum = _mm_add_sd(sum, _mm_unpackhi_pd(sum, sum));
- _mm_store_sd(&ret, sum);
- return ret;
+ _mm_store_s...
2009 Jul 15
0
Fwd: DLLs
...rray1= array[1..2,1..num] of Double;
array2=array[1..num,1..num] of longint;
array3=array[1..num,1..num] of Double;
array4=array[1..num] of longint;
pA1=^array1;
pA2=^array2;
pA3=^array3;
pA4=^array4;
pD=^Double;
procedure learning(loc1:pA1;adj1:pA2;alpha:pD); cdecl;
var
i1,i2,neighs:longint;
sum1,sum2:double;
newloc: array [1..2,1..num] of double;
begin
for i1:=1 to 2 do
for i2:=1 to num do
newloc[i1,i2]:=0;
for i1:= 1 to num do
begin
neighs:=0; sum1:=0; sum2:=0;
for i2:= 1 to num do
begin
if (adj1^[i1,i2]=1) then
begin
neighs:=neighs+1;
sum1:=sum1+loc1[1,i2];
sum2:=sum2+lo...
2015 Jun 01
0
sum(..., na.rm=FALSE): Summing over NA_real_ values much more expensive than non-NAs for na.rm=FALSE? Hmm...
This is a great example how you cannot figure it out after spending
two hours troubleshooting, but a few minutes after you post to
R-devel, it's just jumps to you (is there a word for this other than
"impatient"?);
Let me answer my own question. The discrepancy between my sum2() code
and the internal code for base::sum() is that the latter uses LDOUBLE
= long double (on some system it's only double, cf.
https://github.com/wch/r-source/blob/trunk/src/nmath/nmath.h#L28-L33),
whereas my sum2() code uses double. So using long double, I can
reproduce the penalty of havin...
2002 Apr 23
1
patch: timeout problem solved
...ng to be
- doing and how many bytes there are in the last
- chunk */
- write_int(f_out, s->count);
- write_int(f_out, s->n);
- write_int(f_out, s->remainder);
-
- for (i = 0; i < s->count; i++) {
- write_int(f_out, s->sums[i].sum1);
- write_buf(f_out, s->sums[i].sum2, csum_length);
- }
- } else {
- /* we don't have checksums */
- write_int(f_out, 0);
- write_int(f_out, block_size);
- write_int(f_out, 0);
- }
+ /* we don't have checksums */
+ write_int(f_out, 0);
+ write_int(f_out, block_size);
+ write_int(f_out, 0);
}
@@ -162,57 +146,43 @@...
2007 Jan 25
0
R programming question, one dimensional optimization
...hen?
test?the?
x'Ax/x'Bx.
However?I?dodnot?know?if?there?is?a?way?that?can?calculate?the?x?
automatically?instead?of?
I?typing?different?values?to?get?the?result?and?compare.
===================================================
getMultiVal3?=?function?(a,?b,?cc,?x)?{
+?????i-1;?j=1;?sum=0;?sum2=0
+?????n=nrow(a);?v=?c(x,?cc)
+?????for?(i?in?1:n)?{
+???????for?(j?in?1:n)?{
+??????????sum=sum+a[i,j]*v[i]*v[j];?sum2=sum2+b[i,j]*v[i]*v[j]
+???????}
+?????}
+????return(sum/sum2)
+???}
2012 May 31
0
function to calculate a SMAPE (Symmetric mean absolute percentage error) to avoid the possibility of an inflation caused by zero values in the series
...red)
msSMAPE <- function(obs,pred){
M <- numeric(length(obs))
for (i in 2:length(obs)) {
n <- i-1
M[i] <- mean(obs[1:n])
}
sum1 <- (abs(obs[1]-pred[1]))/(0.5*(abs(pred[1])+abs(obs[1])))
for (i in 2:length(obs)) {
n <- i-1
sum2 <- 0
for (k in 1:n) {sum2 <- sum2+abs(obs[k]-M[k])}
S <- sum2/n
sum1 <-
sum1+(abs(obs[i]-pred[i]))/(0.5*(abs(pred[i])+abs(obs[i]))+S)
}
my.SMAPE <- sum1/length(obs)
return(my.SMAPE)
}
msSMAPE(obs,pred)
[[alternative HTML version deleted]]
2012 Jun 01
0
help to find or fix a SMAPE (Symmetric mean absolute percentage error ) with correction to avoid zero value in the series
...6,7,8)
mSMAPE <- function(obs,pred){
M <- numeric(length(obs))
for (i in 2:length(obs)) {
n <- i-1
M[i] <- mean(obs[1:n])
}
sum1 <- (abs(obs[1]-pred[1]))/(0.5*(abs(pred[1])+abs(obs[1])))
for (i in 2:length(obs)) {
n <- i-1
sum2 <- 0
for (k in 1:n) {sum2 <- sum2+abs(obs[k]-M[k])}
S <- sum2/n
sum1 <-
sum1+(abs(obs[i]-pred[i]))/(0.5*(abs(pred[i])+abs(obs[i]))+S)
}
my.SMAPE <- sum1/length(obs)
return(my.SMAPE)
}
mSMAPE(obs,pred)*100
SMAPEper(obs,pred)
[[alternative HTM...
2012 Jun 04
1
simulation of modified bartlett's test
...riance
A=((n1-1)*v1+(n2-1)*v2+(n3-1)*v3)/(N-k)
#calculate B
B=((N-k)*(log(A)))-((n1-1)*log(v1)+(n2-1)*log(v2)+(n3-1)*log(v3))
#calculate C
C=1+(1/(3*(k-1))*(((1/(n1-1))+(1/(n2-1))+(1/(n3-1)))-(1/(N-k))))
#calculate layard estimator
xbar1=mean(g1)
xbar2=mean(g2)
xbar3=mean(g3)
sum1=sum((g1-xbar1)^4)
sum2=sum((g2-xbar2)^4)
sum3=sum((g3-xbar3)^4)
sum4=sum((g1-xbar1)^2)
sum5=sum((g2-xbar2)^2)
sum6=sum((g3-xbar3)^2)
y= (N*(sum1+sum2+sum3))/((sum4+sum5+sum6)^2)
#calculate bartlett modified statistic
bar2=B/(C*(1/2)*(y-1))
bar2
pv[i]<-pchisq(bar2,2,lower=FALSE)
}
mean(pv<0.01)
mean(pv<0.05)
--...
2015 Mar 13
1
[RFC PATCH v3] Intrinsics/RTCD related fixes. Mostly x86.
...si32(acc1);
-
- for (;i<N;i++)
- {
- sum = silk_SMLABB(sum, x[i], y[i]);
- }
+#include <xmmintrin.h>
+#include "arch.h"
- return sum;
+void xcorr_kernel_sse(const opus_val16 *x, const opus_val16 *y, opus_val32 sum[4], int len)
+{
+ int j;
+ __m128 xsum1, xsum2;
+ xsum1 = _mm_loadu_ps(sum);
+ xsum2 = _mm_setzero_ps();
+
+ for (j = 0; j < len-3; j += 4)
+ {
+ __m128 x0 = _mm_loadu_ps(x+j);
+ __m128 yj = _mm_loadu_ps(y+j);
+ __m128 y3 = _mm_loadu_ps(y+j+3);
+
+ xsum1 = _mm_add_ps(xsum1,_mm_mul_ps(_mm_shuffle_ps(x0,x0,0x00),yj)...