The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
 All Forums
 Origin Forum
 Origin Forum
 sum function

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
sundown Posted - 07/09/2003 : 12:10:42 PM
As a new user of origin can anyone tell me how I can formulate an expression of the type:

col(B) = sum (from j=1 to N) e to the power of |i-j|/X

where j=1 to N are the first to last values in col(A), i is the row number and X is a constant.

i.e. if col(A) =1,2,3 then
col(B)[1] = (e raised to 0)+(e raised to 1/X)+(e raised to 2/X)
col(B)[2] = (e raised to 1/X)+(e raised to 0)+(e raised to 1/X)
col(B)[3] = (e raised to 2/X)+(e raised to 1/X)+(e raised to 0)

Thanks in advance
1   L A T E S T    R E P L I E S    (Newest First)
Mike Buess Posted - 07/09/2003 : 7:04:48 PM
This is the slow LabTalk method...

get col(A) -e NN; // find number of rows
loop (ii,1,NN) {
col(B)[ii]=0;
loop (jj,1,NN) {
kk=abs(ii-jj);
col(B)[ii]+=exp(kk/X);
};
};

This is much faster...

get col(A) -e NN; // find number of rows
temp=data(1,NN); // create a temporary dataset
loop (ii,1,NN) {
temp=col(A);
temp-=ii;
temp=abs(temp);
temp/=X;
temp=exp(temp);
sum(temp);
col(B)[ii]=sum.total;
};
del temp;

It's even faster using the second method in an Origin C function...
void MyFunc(double dX)
{
Worksheet wks = Project.ActiveLayer();
Dataset dA(wks,0);
Dataset dB(wks,1);
int NN = dA.GetSize();
Dataset dTemp;
dTemp.Create(NN);
BasicStats bStat;
for(int i=0; i<NN; i++)
{
dTemp = dA;
dTemp -= (i+1);
dTemp = abs(dTemp);
dTemp /= dX;
dTemp = exp(dTemp);
Data_sum(&dTemp, &bStat);
dB[i] = bStat.total;
}
}


Mike Buess
Origin WebRing Member

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000