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 for Programming
 LabTalk Forum
 ss and rms along column, further corr 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
Heidi01 Posted - 05/15/2014 : 10:43:02 AM
Origin Ver. and Service Release (Select Help-->About Origin):
Operating System: OriginPro 8.50G SR1 Win7 Pro

Hello,

I am new to Origin and consider using it because it seems to be able to handle the computation and graphing of large datasets easier than other spreadsheet software.

Data to be statistically processed is in col(B)[1:n]. I would like to compute the ss values pointwise and store them in col(C)[1:n], i.e.
Row 1 = (data[1]-data[1])^2;
Row 2 = (data[1]-mean[1:2])^2 + (data[2]-mean[1:2])^2;
Row 3 = (data[1]-mean[1:3])^2 + (data[2]-mean[1:3])^2 + (data[3]-mean[1:3])^2 etc.

Similarily for the rms values and store them in col(D)[1:n].

Is there a way to compute them in Scripts within the Set Column Value Property?

I also would welcome any additional information about the estimator (and method) used to compute the result of the correlation of data using the LabTalk DataSet manipulation function corr. The help provided is quite general and leaves far too much space for time consuming interpretations.

Thank you.
5   L A T E S T    R E P L I E S    (Newest First)
Sam Fang Posted - 05/22/2014 : 07:53:29 AM
Case2 is a bug in 85. It has been fixed in 91. It assigned the first element of a vector to a cell.

I made a tool to call NAG function, and sent it to your email which you registered in Origin's forum. I also showed you how to use it in the email.

If you have any question, please let us know.

Sam
OriginLab Technical Services
Heidi01 Posted - 05/22/2014 : 04:59:28 AM
Thank you for the answer.
quote:
Originally posted by Sam Fang

The corr function is same as Analysis: Signal Processing: Correlation for Linear method. And the mean is not removed. Note that there is difference between two, for corr(f,g,k[,N]):
1. k must be a non-negative integer. It can only calculate leading not lagging. For autocorrelation, leading and lagging are same.
2. N means to sum the first N product terms, i.e. sum(f[i]*g[i+k]) i is from 1 to N.

corr(rr, rr, {1:ii}, ii)
will return a vector of length ii, so you can't assign it to a cell col(N)[ii].

Your result of case3 is different from case4 because number of terms in the sum is different (case3 is 16 while case4 is 20).



Where does the difference between case2 and case3 come from?

quote:
[i]It seems that what you want is autocorrelation in time series (www.originlab.com/pdfs/nagcl09/manual/pdf/g13/g13abc.pdf)? If so, you can call NAG function nag_tsa_auto_corr using OriginC code. If you have difficulty in calling NAG functions, please let us know.


Sam
OriginLab Technical Services



Could you help me call the NAG function in order to compute the autocorrelation in time series? I am completely new to Origin C.

Thanks.

Heidi
Sam Fang Posted - 05/20/2014 : 01:31:02 AM
The corr function is same as Analysis: Signal Processing: Correlation for Linear method. And the mean is not removed. Note that there is difference between two, for corr(f,g,k[,N]):
1. k must be a non-negative integer. It can only calculate leading not lagging. For autocorrelation, leading and lagging are same.
2. N means to sum the first N product terms, i.e. sum(f[i]*g[i+k]) i is from 1 to N.

corr(rr, rr, {1:ii}, ii)
will return a vector of length ii, so you can't assign it to a cell col(N)[ii].

Your result of case3 is different from case4 because number of terms in the sum is different (case3 is 16 while case4 is 20).

It seems that what you want is autocorrelation in time series (www.originlab.com/pdfs/nagcl09/manual/pdf/g13/g13abc.pdf)? If so, you can call NAG function nag_tsa_auto_corr using OriginC code. If you have difficulty in calling NAG functions, please let us know.


Sam
OriginLab Technical Services
Heidi01 Posted - 05/16/2014 : 12:56:48 PM
Hello again!

Thank you very much for the script, it works properly at least on a small size data set. It provides a straightforward way to save the data generated within the loop in order to make the result available outside of the loop.

The link you provided contains the description of the algorithm used to compute the correlation using the Correlation tool under the Analysis - Signal Processing submenu (one can choose the normalisation option and between circular and linear correlation).

My question is related to the estimator used for the corr function for which the help is given under this link: http://www.originlab.com/doc/LabTalk/ref/Corr-func .

This syntax allows one to explicitly set the values for the correlation lag (k) and the number N of first points for which the correlation of two datasets is computed in time domain. No mention is given to the parameters associated with the computation using FFT- based algorithms within that help.

Is "corr(dataset1, dataset2, k[, N])" just a mask for the FFT-based implementation or is there a statistical estimator available? Is the mean value being removed from the original datasets before any computation?

Best regards.

I try to move on, but I get weird results with different ways of using "corr(dataset1, dataset2, k[, N])".

1. The original data set is in col(B):
-0,391298304
-0,1156138
-0,786066272
0,254441684
0,528168955
0,582511479
-0,824511745
-0,30864298
0,814638024
-0,265956696
-0,054350531
0,488030619
-0,300911167
0,21427978
-0,693128684
-0,85471069
-0,577309667
-0,376565004
-0,850521694
-0,79196248
-1,10803371
-0,209082839
-0,920860994
-1,054503511
-1,19759902
0,596238457
-0,195208656
-1,342172911
-0,580125948
-0,642852282
0,454506783
-0,812888464

1.If I choose to have my result displayed in column N and I use the Set Column Value property with the script before applying formula:
loop (ii, 1, 16)
{range rr = col(2)[1:ii];
col(N)[ii] = corr(rr, rr, {1:ii}, ii);};
without any line in the experssion to be assigned to col(N), the result dsiplayed is "--" in the first 16 cells of column N.

2. I change that script to
loop (ii, 1, 16)
{range rr = col(2) [1:ii];
col(N)[ii] = corr(rr, rr, {1:ii}, ii);};
without any line in the experssion to be assigned to col(N), the result dsiplayed is
0,045239484
0,136119593
-0,063888433
0,070499766
0,378164245
-0,102123311
0,152356451
-0,099075857
-0,315734294
-0,301279407
-0,32780413
-0,474657993
-0,539137172
-0,687660634
-0,095236138
0,398196606

in the first 16 cells of column N.

Why does inserting a blank space in "range rr = col(2)?[1:ii]" change the result? What is computed? Because...

3. I choose column O to Set Column Value property as
col(O)=corr(col(B), col(B), {1:16}, 16);
with no other script. and I get:

0,398196606
-0,499367985
0,968398278
1,142972908
1,386293192
0,631043606
0,337067752
1,797825957
1,28431317
-0,16828184
-1,689957138
1,300758576
1,574220592
1,404649878
-0,457864878
-0,247827987

which is weird. Again the significance is unclear.

4. I choose column O to Set Column Value property as
col(O)=corr(col(B), col(B), {1:16}, 20);
with no other script. and I get:

2,486970324
1,397864238
2,74996944
3,479724229
3,699094363
2,106140139
1,044300891
3,493668696
2,614592855
1,452353944
-0,509845119
2,134955851
3,877495199
3,70939182
2,982699335
3,926421182

which makes me think twice before using it at all...

Could anybody explain this please?
lkb0221 Posted - 05/16/2014 : 09:54:50 AM
Hi,

Please try the following script:

// Script Start
// Assume col(B) is the second column in your wks
loop(ii,1,wks.col2.nrows)
{
range rr = col(2)[1:ii];
double ref = mean(rr);
col(C)[ii] = ss(rr,ref);
col(D)[ii] = rms(rr);
}
// Script End

And for the correlation problem:
http://www.originlab.com/doc/Origin-Help/Corr1-Algorithm

Zheng
OriginLab

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