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
 Averageing ys for xs with degeneracy.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

total

USA
Posts

Posted - 09/10/2005 :  01:32:21 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
in my set of date there are few (x,y) pairs with the same x, it looks like:
x y
1 5
1 4
1 4
2 5
3 5
3 7
I need to simply average the ys for all the ones, all the twos and so on, this is in order to make a graph for which each x has only one y.
as I have 10000 points of data for which x is changing over 200 different numbers, I cannot do it manually and I wonder what function can do this very simple analyzis.
(if any of you is aware of such a matlab/mathematica/exel function, he is welcome to sugest it)
Thanks
Tal

Mike Buess

USA
3037 Posts

Posted - 09/10/2005 :  10:14:15 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Tal,

Since you didn't indicate your Origin version I'll give you a LabTalk solution that will work in all versions. To try it out just copy the lines of code below to the script window, select all lines and press Enter. If you need to use it more than once you can assign the code to the Custom Routine button as explained here...

http://www.originlab.com/www/support/resultstech.aspx?ID=769&language=English

# Code starts here
%W=%H; // remember name of active wks
get col(1) -e npt; // how many rows?
win -t D; %N=%H; // create new wks and save its name
wo -a 1; // create third column for counts
set %N -er npt; // make sure the wks has enough rows
rr=1; // initialize row number
nn=1; // initialize count
xx=%(%W,1,1); // initialize X value from first row
yy=%(%W,2,1); // initialize Y value (sum) from first row
# loop over remaining rows
loop (i,2,npt) {
if(%(%W,1,i)==xx) {
# if X value matches previous X value...
yy+=%(%W,2,i); // add Y value to sum
nn++; // increment count
} else {
# else record results...
%(%N,1,rr)=xx; // X value to 1st column
%(%N,2,rr)=yy/nn; // average Y value to 2nd column
%(%N,3,rr)=nn; // count to 3rd column
rr++; // increment row #
nn=1; // reset count
xx=%(%W,1,i); // new X value
yy=%(%W,2,i); // new Y value (sum)
};
};
%(%N,1,rr)=xx; // record final X value
%(%N,2,rr)=yy/nn; // record final Y value
%(%N,3,rr)=nn; // record final count

Mike Buess
Origin WebRing Member
Go to Top of Page

total

USA
Posts

Posted - 09/11/2005 :  11:39:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Mike,
Thanks alot for your help


Go to Top of Page

mbst

Austria
Posts

Posted - 12/16/2005 :  07:40:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
till now i use MSAccess to solve such jobs...
but i'm also looking for an xls or origin-tool which calculates mean, stDev and number of values, grouped by one (ore more) alphanumeric columns WITHOUT sorting
greetings
mbst

Go to Top of Page

minimax

348 Posts

Posted - 12/20/2005 :  12:47:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi mbst,

Origin's next version, version 8, will support grouped descriptive statistics.

quote:

till now i use MSAccess to solve such jobs...
but i'm also looking for an xls or origin-tool which calculates mean, stDev and number of values, grouped by one (ore more) alphanumeric columns WITHOUT sorting
greetings
mbst





Max
OriginLab GZoffice
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