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 for Programming
 Forum for Origin C
 Global fitting
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

hgibhar

Germany
12 Posts

Posted - 09/13/2013 :  11:07:26 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hello,

I try to do global fitting with shared parameter on a huge amount of datasets (40 at one time). Using this in the normal dialog does the work, but is slow. Hence, I tried to do Labtalk programming, letting the computer the calculations for the night. This becomes more and more slowly. Hence, I tried to take OriginC. A test with a 3 datasets shows, that this will be quite quickly and might work over night, too.

THe question now is: How can I produce a result report worksheet exactly similar to the normal fitting dialogbox? Everything is done there: the graphs, parameters and errors, statistics. Very well presented form. It is unnecessary, to invent this anew!

Here som code snippets:

Programmatically getting the input data:

---------------
XYRange drInput;

int i;
for(i=1;i<4;i++){
drInput.Add(wks, 0, "X");
drInput.Add(wks, i, "Y");
if(i<3) drInput.Add();
}

vector vX1[3], vY1[3];

for(i=0;i<3;i++){
drInput.GetData(vY1[i], vX1[i], NULL, i);
}

---------------
NLFitSession nlfSession;

// Set Function: a self generated one (in OriginC)
if ( !nlfSession.SetFunction("vgt1") )
ERR_RETURN("Fail to set function!");

for(i=0;i<2;i++){
// Set Data and only need to set the last dataset with global fit mode, as to allow share parameters
if ( !nlfSession.SetData(vY1[i], vX1[i], NULL, i, 3) )
ERR_RETURN("Fail to set data for the first dataset!")

}
if ( !nlfSession.SetData(vY1[2], vX1[2], NULL, 2, 3, DATA_MODE_GLOBAL) )
ERR_RETURN("Fail to set data for the last dataset!")
// Parameter initialization


if ( !nlfSession.ParamsInitValues() )
ERR_RETURN("Fail to init parameters values!")

// Share xc parameter
int nSharedParamIndex = 2; // 1, the index of xc in function, must be DATA_MODE_GLOBAL datamode, or else will fail to share parameters
nlfSession.SetParamShare(nSharedParamIndex);


----------Fitting
bool bRet = nlfSession.Fit(&nFitOutcome); //if success
------------------

Now, there should be something like: "Make Results Report like Origin"

Thank you very much for any hint!

Holger

PS: It seems, that the functions

GetFitResultsStats(RegStats* pRegStats, NLSFFitInfo* pFitInfo, bool bPreDataset = false, int nSetIndex = 0, int nDepIndex = 0)

and

GetFitResultsParams(FitParameter* pFitParameter, RegStats *pstRegStats = NULL, int nDataset = 0, bool bIncDerivedParams = false)

do not work with global fitting. THe Compiler always says "member function NLFitSession::GetFitResultsParams cannot be found".

The function GetFitResultsParams(vector& vParams, vector& vErrors) works.


Origin Ver. 9.0.0 32 bit Operating System: Win 7

Penn

China
644 Posts

Posted - 09/29/2013 :  10:25:07 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

For global fitting with shared parameter, please refer to Fit on multiple datasets with one function, parameters shared, and this example has shown how to get the usage of GetFitResultsStats and GetFitResultsParams. Then you need to generate the report by yourself, and please refer to Output Examples.

Penn
Go to Top of Page

hgibhar

Germany
12 Posts

Posted - 09/30/2013 :  06:31:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hello Penn,

thank you very much for your reply. I have just read the links you sent. The main question was, if there is a simple way to produce the same report as Origin. This seems not to be the case with respect to your mail.
A second remark concerned GetFitResultsStats and GetFitResultsParams. I wrote, that with global fitting the compiler produces an error using GetFitResultsParams(FitParameter* pFitParameter, RegStats *pstRegStats = NULL, int nDataset = 0, bool bIncDerivedParams = false). Instead of using this, the other constructor GetFitResultsParams(vector& vParams, vector& vErrors) works. THis is not mentioned in the OriginC help. And one looks for the mistake, which is in the code (and will not find it).

Thank you for your reply.

Holger
Go to Top of Page

Penn

China
644 Posts

Posted - 10/11/2013 :  05:37:08 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I am afraid there is no simple way to generate the same report as Origin in Origin C.

About the methods you mentioned, could you please try the example in this page to see whether it works or not?

Penn
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