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
 Error Bars
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

krasopater

Bangladesh
2 Posts

Posted - 03/01/2004 :  07:06:34 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi.
I have a problem with error bars.
This problem has been posted but I did not found any solution to my problem.

I have a list of X, Y values in two columns like the following list:

X Y
1 12
1 12
1 13
1 15
2 21
2 23
2 24
2 21
3 33
3 35
3 34
4 21
4 22
4 23

How can I create a 2D X,Y plot graph showing at the same time the standard diviation of each X value (error bars Y) directly from these data????????!!!!!!!!!!!!!!!!!!!
I think Origin can not calculate the SD of each X value simply with this type of Data. However, other software, like Sigmaplot 8.02 can do it in a few clicks.

Thanks

peter.cook

UK
356 Posts

Posted - 03/01/2004 :  10:51:42 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

Yes...I agree this would a nice standard feature for Origin!

You might want to look at
http://www.originlab.com/forum/topic.asp?TOPIC_ID=2924
for Origin C or consider someting like :

// %1 : input x dataset
// %2 : input y dataset
// %3 : output x dataset
// %4 : output mean y dataset
// %5 : output sd dataset

def GenMeanSEXY {
MeanYZero=0/0;
MeanYTop=0/0;
MeanYBot=0/0;
sum(%1);
Numpoints=sum.n;
MaxXValue=sum.max;
sum(%2);
MaxYValue=sum.max;
MinYValue=sum.min;
NumdiffX=1; XStart1=1; XFinish1=1; %3[1]=%1[1];
loop(NumXValue,2,NumPoints) {
If(%1[NumXValue]>%1[XFinish$(NumDiffX)]) {
NumDiffX=NumDiffX+1;
XStart$(NumDiffX)=NumXValue;
%3[NumDiffX]=%1[NumXValue];
};
XFinish$(NumDiffX)=NumXValue;
};
loop(NumXValue,1,NumDiffX) {
NumYValues=XFinish$(NumXValue)-XStart$(NumXValue)+1;
Create TempY -n NumYValues;
Copy -b XStart$(NumXValue) %2 TempY -b 1 -e NumYValues;
Sum(TempY);
delete -s TempY;
%4[NumXValue]=sum.mean;
%5[NumXValue]=sum.sd;
};
MeanYTop=%4[NumDiffX];
If(%3[1]==0) {
MeanYZero=%4[1];
MeanYBot=%4[2];
MinXValue=%3[2];
} else {
MeanYBot=%4[1];
MinXValue=%3[1];
};
};



Cheers,

Pete

Go to Top of Page

krasopater

Bangladesh
2 Posts

Posted - 03/01/2004 :  11:11:07 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks.

I am not familiar with the listing thing, but I will take a look.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 03/01/2004 :  5:02:41 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
This uses the ExtractOneGroup OriginC function discussed by CP in the topic referenced above. (Origin 7.5 SR1)
void sum_all_groups(int nGroupCol = 0, int nDataCol = 1)
{
Worksheet wks = Project.ActiveLayer();
Dataset dGroup(wks, nGroupCol);
vector<ushort> vRowMap;
vRowMap = dGroup;
Worksheet wResult;
wResult.Create();
wResult.AddCol();
wResult.AddCol();
wResult.Columns(1).SetName("Mean");
wResult.Columns(2).SetName("SD");
wResult.Columns(3).SetName("N");
wResult.Columns(2).SetType(OKDATAOBJ_DESIGNATION_ERROR);
BasicStats bsStat;
Data_sum(&dGroup,&bsStat);
int iMin = bsStat.min;
int iMax = bsStat.max;
int nGroup;
for(int i=iMin;i<=iMax;i++)
{
if( sum_one_group(wks, bsStat, vRowMap, i, nDataCol) )
{
wResult.SetCell(nGroup,0,i);
wResult.SetCell(nGroup,1,bsStat.mean);
wResult.SetCell(nGroup,2,bsStat.sd);
wResult.SetCell(nGroup,3,bsStat.N);
nGroup++;
}
}
}

int sum_one_group(Worksheet wks, BasicStats &bsStat, vector<ushort> vRowMap, int nGroupVal, int nDataCol)
{
vector vResult;
if( wks.ExtractOneGroup(vResult, nDataCol, vRowMap, 0, 0, vRowMap.GetSize()-1, nGroupVal) )
{
Dataset dOut;
dOut.Create(vResult.GetSize());
dOut = vResult;
Data_sum(&dOut,&bsStat);
return bsStat.N;
}
return 0;
}


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 03/02/2004 3:11:15 PM
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