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
 Using range as input to MEAN() or STDDEV()?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

johannes.kastl

Germany
71 Posts

Posted - 08/09/2013 :  08:07:12 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi everyone,

I fumbled around with calculating cell values today, but got nowhere with the mean and stddev functions. I just wanted to calculate the mean of each row for three columns.

I tested further with labtalk:
range TEST=Col(A);mean(TEST)=;
calculates the mean of the whole column A.


range TEST=Col(A)[1:10];mean(TEST)=;code] calculates the mean of rows 1 to 5 of column A.



But I found no way to get more than one column into the mean function, although it should accept a range as input, according to http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:Mean_%28function%29.

Same for stddev(). And the same is true for 'blocks of cells'.

Do I understand something wrong? Does mean only accept whole columns?

Or is the reason the same as for the range.getsize(), which only returns values of the first column, if the input range is a block of cells? (http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:Range_Notation&rdfrom=http%3A%2F%2Fwiki.originlab.com%2F%7Eoriginla%2Fwiki%2Findex.php%3Ftitle%3DLabTalk%3ARange_Notation%26redirect%3Dno#Methods_of_Range)

Thanks in advance,
Johannes

Origin Ver. and Service Release (Select Help-->About Origin): 9.0.0G SR2, Operating System: WinXP

johannes.kastl

Germany
71 Posts

Posted - 08/12/2013 :  09:09:54 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Christy,

thanks for your answer.

I should have been more clean in my first post. I already know of some ways to get the row statistics. Disadvantage for rowstats is that it can't be automatically recalculated, which is possible by using either "Calculate values" or by using the function in the Statistics-Menu.

I was just wondering why mean() and stddev() do not accept a valid range as input. If there was
- an error in my statements or
- an error in the description to these functions (and they do not accept all ranges as input) or
- a bug in Origin, which leads to this behaviour.

Sorry for the confusion.

Regards,
Johannes
Go to Top of Page

greg

USA
1378 Posts

Posted - 08/15/2013 :  4:19:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
mean( ), stddev( ), etc. all take vector arguments which means they are limited to a single dimension array, so any range you declare with the intent of passing as an argument to these functions must be to a single column (or dataset) or sub-range of that column.

Origin does not outright reject a multi-column range and instead returns the value for the first column in the range. Odd, but there you have it.

If all you need are mean and SD for a contiguous block of cells, you can use the stats X-Function:

range raMC = 2[10]:6[35]; // Range from column 2 row 10 to column 6 row 35
stats raMC;
ty Mean is $(stats.mean) with SD of $(stats.sd);
Go to Top of Page

johannes.kastl

Germany
71 Posts

Posted - 08/16/2013 :  05:07:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Greg,

thanks for clarifying.

It would be nice if the difference between vectors and ranges in general would be explained somewhere in the help or the wiki (or have I just not found it?).

And the Just-one-column-thingy should be in the explanations for mean, stddev etc., e.g. here:
http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:StdDev_%28function%29
http://wiki.originlab.com/~originla/ltwiki/index.php?title=LabTalk:Mean_%28function%29
http://wiki.originlab.com/~originla/ltwiki/index.php?title=Script:LabTalk-Supported_Functions
http://ocwiki.originlab.com/index.php?title=XFProgramming:Using_Range_in_X-Function

Especially as the descriptions for mean() and stddev() are pretty short... ;-)

Regards,
Johannes
Go to Top of Page

AlexD2

France
19 Posts

Posted - 01/12/2014 :  11:45:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
One can apparently also use the -v option switch of the range declaration:

range -v rRow = 1[3]:8[3]; // Defines a range (vector type?) rRow
// over the 3rd row between columns 1 and 8
mean(rRow)=; // Gives the expected row mean

Not sure how general is this trick though...

If someone can clarify (or give a link) for the subtle difference between e.g. dataset, vector, and range defined with the -v switch, that would be much helpful...

Many thanks,

AlexD2
Go to Top of Page

greg

USA
1378 Posts

Posted - 01/14/2014 :  4:03:31 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
The -v switch is new in Origin 9.1.

http://wikis/ltwiki/index.php?title=LabTalk%3ARange_Notation#Option_Switch_-vOption_Switches

The range points to data - which need not be contiguous - and then acts like a single dimension array of data stored in column major order.

The range can currently only be used in an X Function where the Input type is vector.
Stats is such an X Function, so stats of a row can easily be determined:

row = 7;
range -v raRow = 1[row]:end[row];
stats raRow;
stats.mean=;

Here is a non-contiguous example:
newbook;
loop(ii,1,5)
{
wcol(ii)=data($(ii),$(ii+5));
}
range -v raV = (col(1)[1:3],col(3)[2:4],col(5)[3:6]);
stats raV;
stats.=;
Go to Top of Page

AlexD2

France
19 Posts

Posted - 01/14/2014 :  4:31:50 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Beautiful!

Thank you!

AlexD2
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