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
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Moving averages
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Sarath_2010

22 Posts

Posted - 06/28/2013 :  11:13:13 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
I wanted to perform simple moving average of a column data. For instance, for 5 point moving average, the fifth row of the result column should be the average of the first five rows of the data column, the sixth row of the result column should be the average of row 2 to row 6 of the data column and so on. This can be easily performed in Excel, but I find it impossible in Origin. Please help.

A similar problem is to find the exponential moving averages of a column data, popular in financial markets. Any suggestions?

Thanks in advance!

snowli

USA
1388 Posts

Posted - 06/28/2013 :  11:59:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Which Origin version are you using?

We added single moving average in Origin 9.0.

You can add a new column. Then in Set Column Values dialog, find the function from
F(x): Statistics: movavg()

You can set the formula to be movavg(col(A), 2, 2) to get moving average of 5 points. 1st 2 is 2 points before current point. 2nd 2 is 2 points after the point.

We don't have exponential moving averaging yet but maybe you can use formulas after calculating simple moving average to get exponential moving averaging. We will investigate EMA further and hopefully add it in future version.

Thanks, Snow Li
OriginLab Corp.
Go to Top of Page

Sarath_2010

22 Posts

Posted - 06/28/2013 :  4:20:05 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I am using Origin 8.0. Is there any way out?
Go to Top of Page

snowli

USA
1388 Posts

Posted - 06/28/2013 :  5:32:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

There is LabTalk Script on this page
http://www.originlab.com/www/support/resultstech.aspx?ID=298&language=English

You can use it to calculate Moving Average.

Thanks, Snow
Go to Top of Page

Sam Fang

293 Posts

Posted - 07/07/2013 :  10:56:35 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Exponential moving average can also be done in Origin.

Suppose you want to perform exponential moving average on Column B with time period of 10. You can right click on Column C, and select Set Column Values from the shortcut menu. In the Set Values dialog, make following settings:



Then exponential moving average data will be shown in Column C. For other time period values, you need change the value 10 and 11 to other specified values in Before Formula Scripts and From value at the top of the dialog.

Sam
OriginLab Technical Services

Edited by - Sam Fang on 07/07/2013 11:06:14 PM
Go to Top of Page

fusjen63

France
6 Posts

Posted - 12/01/2015 :  12:05:11 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

How can I manage to get moving standard deviation with Origin 8.5 please ?
I've tried different things with windows commande but do not seem to work..

Thanks in advance
Go to Top of Page

snowli

USA
1388 Posts

Posted - 12/01/2015 :  2:32:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello,

Since Origin 9.1, we supports subrange notation in Set Column Values, so that you can easying doing moving calculations.

E.g. the following will do moving standard deviation of range of cells from 5 above the current cell to 5 after the current cell.
stddev(col(A)[i-5:i+5])

In your version, you may need to write LT script to loop through all rows to get moving standard deviation.

Thanks, Snow Li
OriginLab Corp.
Go to Top of Page

fusjen63

France
6 Posts

Posted - 12/02/2015 :  12:11:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Ok thank you for your answer.
I actually tried to use LT but do not understand why, do not work.
I wrote this in the script window :

"for (i=1; i<12; i+=4);
{
range aa = 1[i]:1[i+3];
range bb = 2[i];
bb = Stddev(aa);
};"

I want to average block of 4 cells, along all my column 1(12rows) and put the value in column 2 at the first line of the cells block.

When I execute i do not have error message but only got double dash line in the column 2...

Thanks for your help
Go to Top of Page

fusjen63

France
6 Posts

Posted - 12/02/2015 :  12:17:42 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
OUPS I meant standard deviation not average
Go to Top of Page

snowli

USA
1388 Posts

Posted - 12/02/2015 :  12:40:36 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Just remove ; at the end of for loop. The folloing works.

for (i=1; i<12; i+=4)
{
range aa = 1[i]:1[i+3];
range bb = 2[i];
bb = Stddev(aa);
}

Thanks, Snow
Go to Top of Page

fusjen63

France
6 Posts

Posted - 12/03/2015 :  03:45:44 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It does not work with my version.. (Origin 8.5 Academic)
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 12/03/2015 :  3:20:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

This should work though it might slow down the speed:
for (i=1; i<12; i+=4) {
  range aa = 1[i]:1[i+3];
  range bb = 2[i];
  //bb = Stddev(aa);
  sum(aa);
  bb=sum.sd;
}
--Hideo Fujii
OriginLab
Go to Top of Page

fusjen63

France
6 Posts

Posted - 12/04/2015 :  04:53:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
HI,

Stil does not work.. I really do not understand why since I have no code error but looks like it does not manage to deal with index.

I tried on different version of origin (7 and 8pro) on my collegues computer but same conclusions. MOreover i do not find standard deviation function in previous version.

Thanks
Go to Top of Page

Hideo Fujii

USA
1582 Posts

Posted - 12/04/2015 :  4:21:37 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I have checked again to see whether it works on my Origin 8.5 (SR1, b161), or not. This shouldn't matter
whether Origin is Pro or not. It worked as below. How did you run the script?



To run the script,
1) Make sure, your workbook is activated as selected in front.
2) Open the Script window, and copy-and-paste the script into the Script window.
3) Highlight ALL lines of the script, and hit ENTER key to run the selection.

Hope the problem is straighten out now.

--Hideo Fujii
OriginLab
Go to Top of Page

fusjen63

France
6 Posts

Posted - 12/07/2015 :  08:06:39 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Yes it works !! Thanks a lot !

Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000