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
 Fitting routine for a set of graphs
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

a.abc.b35

175 Posts

Posted - 05/19/2011 :  12:49:40 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 8 , SR0
Operating System: windows 7
..................
I am sure many have done it. I am just not able to find the write resources, so am posting it here.
...
I have 100 graphs (X vs Y with Y_Err). The graphs are names systematically so that they can be called to a program. I also have a fitting function (from NLFIT dialog) which I can fit to this data. After the auto initialization process, I have to hit the multiple iteration button, await a while and then hit OK. This I have to repeat for all the 100 files. Can anyone tell me/guide me how to make a routin in origin c where I can do all these automatically ? I have already saved the non linear fitting function as a theme. Now, I open every graph and fit it through a custom made radio button. Just repeating it 100 times is really annoying. I hope someone can help me quickly. Thanks in advance.
PS: I have basic idea about origin C. So a little help may move this mountain !

AB

a.abc.b35

175 Posts

Posted - 05/19/2011 :  03:04:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have found a code in
http://ocwiki.originlab.com/index.php?title=OriginC:Fit_Multiple_XY_Data_in_a_loop
....
The code work fine for the sample Gauss function used with a sligh modification for my system :use FitSession.SetFunction(strFunc) in set function.
....
THe problem is when I try to replace the gauss function by a custom made function, I get the following error message :
fit failed:-1->Fit did not converge - reason unknown.
...........
Can anyone help me with this. The custom made fitting function works fine if I plot a X,Y plot and use it there via NLFIT dialog.
....
Here is the code for the custom made function:

y = f0 + (2.0/3.0)*f2*(cos(x-x0))^2 + (8.0/15.0)*f4*(cos(x-x0))^4+ (16.0/35.0)*f6*(cos(x-x0))^6 + (128.0/315.0)*f8*(cos(x-x0))^8;

f0 ,f2,f4,f6,f8,x0 are listed as parameters and it is saved as a *.FDE file. All the f-s are initialized to 20.0 and x0 = 3.3, to begin with.
...


AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 05/19/2011 :  03:10:16 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here I give a dataset to try the fit : (it is Gaussain though)
(do not know a better option to give the data in the forum ):
one can copy this data to origin and paste it to columns if he/she hits ctrl+v after selecting the Long name box of X column only!

X Y


1.5882 34.61427
1.62301 34.66363
1.65782 34.72151
1.69263 34.78907
1.72744 34.86755
1.76225 34.9583
1.79706 35.06271
1.83187 35.18229
1.86668 35.31856
1.90149 35.4731
1.9363 35.6475
1.97111 35.84334
2.00592 36.06214
2.04073 36.30537
2.07554 36.57437
2.11035 36.87033
2.14516 37.19425
2.17996 37.54689
2.21477 37.9287
2.24958 38.33984
2.28439 38.78008
2.3192 39.24878
2.35401 39.74487
2.38882 40.26679
2.42363 40.81251
2.45844 41.37947
2.49325 41.96463
2.52806 42.56444
2.56287 43.17488
2.59768 43.79146
2.63249 44.40933
2.6673 45.02324
2.70211 45.62771
2.73692 46.21703
2.77173 46.78538
2.80654 47.32691
2.84135 47.83585
2.87616 48.30661
2.91097 48.73388
2.94578 49.11271
2.98059 49.43863
3.0154 49.70773
3.05021 49.91675
3.08501 50.06311
3.11982 50.14501
3.15463 50.16141
3.18944 50.11213
3.22425 49.99777
3.25906 49.81974
3.29387 49.58026
3.32868 49.28225
3.36349 48.9293
3.3983 48.52562
3.43311 48.07592
3.46792 47.58535
3.50273 47.05937
3.53754 46.50368
3.57235 45.92409
3.60716 45.32647
3.64197 44.71657
3.67678 44.1
3.71159 43.48214
3.7464 42.86805
3.78121 42.26241
3.81602 41.66946
3.85083 41.093
3.88564 40.53633
3.92045 40.00225
3.95526 39.49304
3.99006 39.01051
4.02487 38.55596
4.05968 38.13024
4.09449 37.73379
4.1293 37.36663
4.16411 37.02845
4.19892 36.71865
4.23373 36.43633
4.26854 36.1804
4.30335 35.94958
4.33816 35.74247
4.37297 35.55756
4.40778 35.39331
4.44259 35.24812
4.4774 35.12041
4.51221 35.00861
4.54702 34.91123
4.58183 34.82679
4.61664 34.75394
4.65145 34.69138
4.68626 34.63791



AB

Edited by - a.abc.b35 on 05/19/2011 03:12:35 AM
Go to Top of Page

Penn

China
644 Posts

Posted - 05/19/2011 :  06:13:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I have tried and found that the error existed in Origin 8 SR0. However, such problem does not exist in Origin 8 SR6. Maybe you can upgrade to Origin 8 SR6 from this page and then try again.

Penn
Go to Top of Page

a.abc.b35

175 Posts

Posted - 05/19/2011 :  3:14:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I have tried in SR6 and the problem is still there !

AB
Go to Top of Page

Penn

China
644 Posts

Posted - 05/19/2011 :  9:44:48 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I have tried again, and it works in my computer with Origin 8 SR6. You can see the results I got in the following image. The upper is got by GUI, and the lower is got by Origin C, with the fitting function you provided.



Penn
Go to Top of Page

a.abc.b35

175 Posts

Posted - 05/20/2011 :  5:41:25 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
It works in SR 6 now. Sorry for the confusion. I had done some silly mistake inside the code.

AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 05/20/2011 :  5:45:10 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
But I have one more problem. That is mostly to do with my inability to understand the code I guess. I need to make sure that the weighing method is set to Statistical, reduced chi square is not used for error calculation and also the standard errors for each parameter are imported to the worksheet created ! Because it works automatically, without plotting any graph, I can't see what it is doing. I only see the final result. Could you please help me with that.


for readiness, I put the code here (it's already in the link though)
#include <Origin.h>
#include <..\originlab\NLFitSession.h>
// assume active worksheet with XYYYY data, all with a single peak
// so we can fit all of them to gauss function and gnerate a new worksheet to hold the fitting results.
void MultiColFit()
{
    Worksheet wks = Project.ActiveLayer();
    if(!wks)
        return;
    
    Worksheet wksOut;
    wksOut.Create();
    wksOut.SetName("ResultsGauss");
    
    fit_all_cols(wks, wksOut);
}
 
static bool fit_all_cols(Worksheet& wks, Worksheet& wksOutput, string strFunc = "Gauss")
{
    NLFitSession    FitSession;
    int             nDataIndex = 0; // only one set in our case
    DWORD           dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
    
    // 1. Set fucntion
    if(!FitSession.SetFunction(strFunc)) // set function, category name can be ignore
        return error_report("invalid fit function");
    
    vector<string>  vsParamNames;
    int             nNumParamsInFunction = FitSession.GetParamNamesInFunction(vsParamNames);
    int             nFitOutcome, nFitErr = -1;
    
    for(int nYCol = 1; nYCol < wks.GetNumCols(); nYCol++)
    {
        DataRange   drInputData;
        drInputData.Add(wks, 0, "X");
        drInputData.Add(wks, nYCol, "Y");
        int         nNumData = drInputData.GetNumData(dwRules);
        ASSERT(1==nNumData);
        
        //2 set the dataset
        vector  vX1, vY1;
        drInputData.GetData( dwRules, nDataIndex, NULL, NULL, &vY1, &vX1 );     
        if(!FitSession.SetData(vY1, vX1, NULL, nDataIndex, nNumData))  
            return error_report("err setting data");
    
        // 3. Call parameter init codes to init parameters
        if(!FitSession.ParamsInitValues())
            return error_report("err ParamsInitValues");
        // 4. Iterate with default settings
        if(!FitSession.Fit(&nFitOutcome))
        {
            string strOutcome = FitSession.GetFitOutCome(nFitOutcome);
            printf("fit failed:%d->%s\n", nFitErr, strOutcome);
            return false;
        }
        // 5. success, get results and put to wksOutput
        FitParameter    params[20];// whatever the max possible number of parameters in your function
        RegStats        fitStats;
        NLSFFitInfo     fitInfo;
        FitSession.GetFitResultsStats(&fitStats, &fitInfo, false, nDataIndex);
        FitSession.GetFitResultsParams(params, &fitStats);
        _append_fit_results(wksOutput, vsParamNames, params, fitStats, fitInfo);
    }
    
    return true;
}
static void _append_fit_results(Worksheet& wks, const vector<string>& vsParamNames, const FitParameter* pParams, const RegStats& fitStats, const NLSFFitInfo& fitInfo)
{
    Column  c0Time = wks.Columns(0);
    int     nR1 = c0Time.GetUpperBound();
    // check if empty, then setup cols
    if(nR1 < 0)
    {
        vector<string> vsExtraCols = {"Tick Count", "Adj Rsquare", "Iterations"};
        int nTotalCols = vsParamNames.GetSize() + vsExtraCols.GetSize();
        if(wks.GetNumCols() < nTotalCols)
        {
            wks.SetSize(0, nTotalCols);
            vector<string> vs;vs = vsExtraCols;
            vs.Append(vsParamNames);        
            for(int nCol = 0;nCol < vs.GetSize();nCol++)
            {
                Column cc = wks.Columns(nCol);
                cc.SetLongName(vs[nCol]);
            }
        }
    }
    nR1++; 
    wks.SetCell(nR1, 0, GetTickCount()/1000.0);
    wks.SetCell(nR1, 1, fitStats.AdjRSq);
    wks.SetCell(nR1, 2, fitInfo.Iterations);
    //fit parameters
    for(int ii = 0, nCol = 3; ii < vsParamNames.GetSize(); ii++, nCol++)
    {
        wks.SetCell(nR1, nCol, pParams[ii].Value);
    }
}


AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 05/20/2011 :  5:47:49 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Also the "wksOut.SetName("ResultsGauss");" does not set the name of the worksheet. it just comes out as Book1 or Book2 etc.

AB
Go to Top of Page

Penn

China
644 Posts

Posted - 05/23/2011 :  03:30:28 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I am afraid that you cannot set the weighting method to Statistical with Origin 8 in Origin C. And so, the reduced chi square will be used for error calculation. However, with the latest version, Origin 8.5.1, both can be done easily. To get the error, you can refer to the FitParameter structure. The following code is the example, and please pay attention to the red lines. If you are interested in Origin 8.5.1, you can download a free demo from this page and then have a try the following code.

void MultiColFit()
{
    Worksheet wks = Project.ActiveLayer();
    if(!wks)
        return;
    
    Worksheet wksOut;
    wksOut.Create();
    
    // set worksheet name
    wksOut.SetName("Worksheet");
    // set workbook name
    wksOut.GetPage().SetName("Workbook");
    
    fit_all_cols(wks, wksOut);
}
 
static bool fit_all_cols(Worksheet& wks, Worksheet& wksOutput, string strFunc = "NewFunction")
{
    NLFitSession    FitSession;
    int             nDataIndex = 0; // only one set in our case
    DWORD           dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
    
    // 1. Set fucntion
    if(!FitSession.SetFunction(strFunc)) // set function, category name can be ignore
        return error_report("invalid fit function");
    
    vector<string>  vsParamNames;
    int             nNumParamsInFunction = FitSession.GetParamNamesInFunction(vsParamNames);
    int             nFitOutcome, nFitErr = -1;
    
    for(int nYCol = 1; nYCol < wks.GetNumCols(); nYCol++)
    {
        DataRange   drInputData;
        drInputData.Add(wks, 0, "X");
        drInputData.Add(wks, nYCol, "Y");
        int         nNumData = drInputData.GetNumData(dwRules);
        ASSERT(1==nNumData);
        
        //2 set the dataset
        vector  vX1, vY1;
        drInputData.GetData( dwRules, nDataIndex, NULL, NULL, &vY1, &vX1 );     
        if(!FitSession.SetData(vY1, vX1, NULL, nDataIndex, nNumData))  
            return error_report("err setting data");
    
        // 3. Call parameter init codes to init parameters
        if(!FitSession.ParamsInitValues())
            return error_report("err ParamsInitValues");
        
        // set weight as Statistics
        if( !FitSession.SetWeightData(WEIGHT_STATISTICAL, 0, 0 ,0) )
            return error_report("err SetWeightData");
        // not use reduced chi square for error calculation
        FitSession.SetScaleParamError(false);
        
        // 4. Iterate with default settings
        if(!FitSession.Fit(&nFitOutcome))
        {
            string strOutcome = FitSession.GetFitOutCome(nFitOutcome);
            printf("fit failed:%d->%s\n", nFitErr, strOutcome);
            return false;
        }
        // 5. success, get results and put to wksOutput
        FitParameter    params[20];// whatever the max possible number of parameters in your function
        RegStats        fitStats;
        NLSFFitInfo     fitInfo;
        FitSession.GetFitResultsStats(&fitStats, &fitInfo, false, nDataIndex);
        FitSession.GetFitResultsParams(params, &fitStats);
        _append_fit_results(wksOutput, vsParamNames, params, fitStats, fitInfo);
    }
    
    return true;
}
static void _append_fit_results(Worksheet& wks, const vector<string>& vsParamNames, const FitParameter* pParams, const RegStats& fitStats, const NLSFFitInfo& fitInfo)
{
    Column  c0Time = wks.Columns(0);
    int     nR1 = c0Time.GetUpperBound();
    // check if empty, then setup cols
    if(nR1 < 0)
    {
        vector<string> vsExtraCols = {"Tick Count", "Adj Rsquare", "Iterations"};
        int nTotalCols = vsParamNames.GetSize()*2 + vsExtraCols.GetSize();
        if(wks.GetNumCols() < nTotalCols)
        {
            wks.SetSize(0, nTotalCols);
            vector<string> vs;vs = vsExtraCols;

            for(int iPara=0; iPara<vsParamNames.GetSize(); iPara++)
            {
            	vs.Add(vsParamNames[iPara]);
            	vs.Add(vsParamNames[iPara]+"_error");
            }
            //vs.Append(vsParamNames);        
            for(int nCol = 0;nCol < vs.GetSize();nCol++)
            {
                Column cc = wks.Columns(nCol);
                cc.SetLongName(vs[nCol]);
            }
        }
    }
    nR1++; 
    wks.SetCell(nR1, 0, GetTickCount()/1000.0);
    wks.SetCell(nR1, 1, fitStats.AdjRSq);
    wks.SetCell(nR1, 2, fitInfo.Iterations);
    //fit parameters

    for(int ii = 0, nCol = 3; ii < vsParamNames.GetSize(); ii++, nCol+=2)
    {
        wks.SetCell(nR1, nCol, pParams[ii].Value);
        wks.SetCell(nR1, nCol+1, pParams[ii].Error);
    }
}

About renaming the worksheet, maybe you just want to rename the workbook, but not worksheet. Renaming both worksheet and workbook, please refer to the red lines in above code.

Penn
Go to Top of Page

a.abc.b35

175 Posts

Posted - 06/11/2011 :  12:27:24 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Penn,
Your modified code helped me a lot ( to say the least). Thanks a lot Penn. I very much appreciate the help. You have saved a lot of my time.

I have one question though, the way the program works now (as i understood and saw with my fitting), it depends a lot on the parameter initialization, and rightly so. Now I have suppose 10 Y columns in the worksheet. For the 2nd Y column, suppose the parameter initialization is not good and the fit fails. So I get an error message with its possible cause. But then the function aborts there ( because of the return statements in the fit poly function). So, even if the following Y columns give a good fit, it does not run ! Could you please guide me how to modify it so that even if it fails for a Ycol value (say 2nd y col), it will give me an error message for it but will go to the next Y columns and perform the fit for those.

AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 06/12/2011 :  10:56:04 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Is there a way I can control the constraints part from the fitting code in origin C ? I have imposed a constraint in my fitting function "NewFunction". If I fit from the NLFit window (Ctrl+Y) , the fit works just fine and i get the correct parameters. But if I try to fit by the routine here, it'll give me weird results for that particular dataset. My guess is if I could put a limit/control one of the fit parameters, here,peak center (assume it's a gauss fit)..will solve my problem..How are you going to limit the peak position such that xc is +/= 0.5 from the initial value set by fit parameter initialization ?
I did it in the NLFit window and get correct results. But with the routin here, it fails. Is the routin not able to access the constraint set by me ?

AB
Go to Top of Page

Penn

China
644 Posts

Posted - 06/13/2011 :  06:12:32 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi AB,

To continue the fitting on the left Y columns, you can change the return value of the fit_all_cols function. Because of the return value, the fitting is aborted when meeting errors. You can pay attention to the red lines of the following changes.

static void fit_all_cols(Worksheet& wks, Worksheet& wksOutput, string strFunc = "NewFunction")
{
    NLFitSession    FitSession;
    int             nDataIndex = 0; // only one set in our case
    DWORD           dwRules = DRR_GET_DEPENDENT | DRR_NO_FACTORS;
    
    // 1. Set fucntion
    if(!FitSession.SetFunction(strFunc)) // set function, category name can be ignore
        return; // error_report("invalid fit function");
    
    vector<string>  vsParamNames;
    int             nNumParamsInFunction = FitSession.GetParamNamesInFunction(vsParamNames);
    int             nFitOutcome, nFitErr = -1;
    
    for(int nYCol = 1; nYCol < wks.GetNumCols(); nYCol++)
    {
        DataRange   drInputData;
        drInputData.Add(wks, 0, "X");
        drInputData.Add(wks, nYCol, "Y");
        int         nNumData = drInputData.GetNumData(dwRules);
        ASSERT(1==nNumData);
        
        //2 set the dataset
        vector  vX1, vY1;
        drInputData.GetData( dwRules, nDataIndex, NULL, NULL, &vY1, &vX1 );     
        if(!FitSession.SetData(vY1, vX1, NULL, nDataIndex, nNumData))  
            return; // error_report("err setting data");
    
        // 3. Call parameter init codes to init parameters
        if(!FitSession.ParamsInitValues())
            return; // error_report("err ParamsInitValues");
        
        // set weight as Statistics
        if( !FitSession.SetWeightData(WEIGHT_STATISTICAL, 0, 0 ,0) )
            return; // error_report("err SetWeightData");
        // not use reduced chi square for error calculation
        FitSession.SetScaleParamError(false);
        
        // 4. Iterate with default settings
        if(!FitSession.Fit(&nFitOutcome))
        {
            string strOutcome = FitSession.GetFitOutCome(nFitOutcome);
            printf("fit failed:%d->%s\n", nFitErr, strOutcome);
            //return false;
            continue;
        }
        // 5. success, get results and put to wksOutput
        FitParameter    params[20];// whatever the max possible number of parameters in your function
        RegStats        fitStats;
        NLSFFitInfo     fitInfo;
        FitSession.GetFitResultsStats(&fitStats, &fitInfo, false, nDataIndex);
        FitSession.GetFitResultsParams(params, &fitStats);
        _append_fit_results(wksOutput, vsParamNames, params, fitStats, fitInfo);
    }
    
    // return true;
}

To set the constraints, you can use the following method:

bool NLFitSession::SetEnableLinearConstraints(bool bConstraints/* = true */, LPCSTR lpcszLinearConstraints/* = NLL*/)
// the first parameter enables constraints, the second is the constraint string


You can use this method after setting fitting function. For example:

if(!FitSession.SetFunction(strFunc)) // set function, category name can be ignore
    return; // error_report("invalid fit function");
if(!FitSession.SetEnableLinearConstraints(true, "xc < xc(i)+0.5; xc > xc(i)-0.5; "))
    return;


Penn
Go to Top of Page

a.abc.b35

175 Posts

Posted - 06/14/2011 :  10:30:29 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Penn, just one question, is this a new method you made (for constraints) or it is already there ? Am using OriginPro 8.5.1 now.

AB
Go to Top of Page

Penn

China
644 Posts

Posted - 06/14/2011 :  9:49:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi AB,

This is a method already there, but not a new method, and you can just use it.

Penn
Go to Top of Page

a.abc.b35

175 Posts

Posted - 06/17/2011 :  11:45:35 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes Penn, I am using it. Thanks a lot. But I have another problem which is strange! here it is :
..............
I have a worksheet with one X and multiple Y cols,say,B,C,D,... etc.
Now I am trying the Gauss fit from both that fitting routine and also by plotting graphs of the individual data. In both cases, it'll fail for a particular dataset,say,C. The area will come out to be NEGATIVE. It says fit converged, tolerance limit (1E-9) satisfied, but actually it just draws a straight line instead of gauss fit to the data !!!! The data is similar to other data in B or D cols. I see no reason why it should fail. The problem, I guess comes form the parameter initialization. For C dataset, the area is initialized to a negative value, and also the peak center is not calculated properly !!! If I manually change the area to a positive value, then it can fit properly,otherwise, it FAILS!!!
How can this happen. I was just going to buy the full version of Origin 8.5 but now this makes me skeptical about it, especially after reading about so many bugs in origin 8.5.1 in other threads(http://www.originlab.com/forum/topic.asp?TOPIC_ID=9401) of the forum. For your convenience, I give you two of my datasets, the fits, and parameter initialization, and everything works fine for dataset B, but fails for C.
(1st col is A(X), 2nd is B(Y),3rd is C(Y))
2.07694 1574.3683 1633.5382
2.11185 1582.1732 1636.4712
2.14675 1595.7729 1650.8879
2.18166 1603.7537 1652.6119
2.21657 1608.2394 1666.7631
2.25147 1634.3715 1685.6224
2.28638 1654.8857 1705.8212
2.32129 1668.9076 1732.6846
2.35619 1686.1226 1733.8258
2.3911 1697.11 1764.639
2.42601 1715.4669 1767.8895
2.46091 1736.6769 1795.924
2.49582 1753.0524 1816.5903
2.53073 1772.6149 1822.4773
2.56563 1777.6954 1837.7489
2.60054 1809.4084 1868.7568
2.63545 1840.8712 1891.0781
2.67035 1844.0317 1896.1881
2.70526 1868.0109 1927.5671
2.74017 1891.3059 1941.8713
2.77507 1903.8109 1960.7792
2.80998 1922.3689 1986.8984
2.84489 1938.3575 1993.7991
2.87979 1952.8032 2024.821
2.9147 1970.3834 2032.3478
2.94961 1984.288 2049.2961
2.98451 1992.9974 2053.8162
3.01942 1988.606 2063.7783
3.05432 1994.047 2056.3879
3.08923 2001.5004 2064.7078
3.12414 2000.8922 2069.6909
3.15904 2009.5912 2071.5991
3.19395 2001.3358 2075.4358
3.22886 1994.5823 2062.5476
3.26376 2001.9745 2066.176
3.29867 1981.1908 2050.104
3.33358 1974.926 2046.8947
3.36848 1958.9303 2029.337
3.40339 1932.1569 2004.7542
3.4383 1921.0345 1988.1709
3.4732 1905.0044 1973.9598
3.50811 1891.1707 1967.4019
3.54302 1871.3937 1939.3961
3.57792 1861.0045 1920.6899
3.61283 1843.8053 1902.6864
3.64774 1819.7697 1881.0408
3.68264 1802.9304 1869.8195
3.71755 1772.3313 1836.7976
3.75246 1765.4304 1824.5826
3.78736 1744.5422 1799.8907
3.82227 1722.5231 1786.9935
3.85718 1706.088 1764.2385
3.89208 1677.9274 1745.8217
3.92699 1670.6077 1737.7988
3.9619 1645.8828 1718.2363
3.9968 1633.5383 1690.7
4.03171 1611.5856 1672.5507
4.06662 1592.2053 1659.6421
4.10152 1591.2611 1651.0039
4.13643 1579.9968 1630.371
4.17134 1564.6494 1627.5604

AB
Go to Top of Page

a.abc.b35

175 Posts

Posted - 06/17/2011 :  11:52:56 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is the screen shot of the fit :


AB
Go to Top of Page

Penn

China
644 Posts

Posted - 06/21/2011 :  03:39:10 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi AB,

The algorithm for initializing the parameters automatically does not always work great for all datasets. It also depends on the dataset itself and the fitting function. And we will try to improve the algorithm to make it work better. Thanks for reporting this.

And for your issue, you can initialize the parameters manually.

Penn
Go to Top of Page

a.abc.b35

175 Posts

Posted - 07/01/2011 :  12:32:40 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That means I have to walk through all of them manually because one does not know which one is going to fail. This ambiguity makes the whole process questionable. Could you please suggest me a solution/ give me the better "algorithm" (after it is developed). I hope Origin is not going to charge me anything for that upgrade, right ?

AB
Go to Top of Page

Penn

China
644 Posts

Posted - 07/03/2011 :  10:41:22 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi AB,

We have fixed this problem in our in-house build. However, currently, you can change the parameter initial code of the Gauss function to solve your problem. To do that, follow the step below:

1. Select menu "Tools: Fitting Function Organizer" to open the Fitting Function Organizer.
2. Choose the Gauss function (Origin Basic Functions: Gauss) from the fitting function list in the left panel.
3. In the right panel, position to the Parameter Initialization text box, comment out the original initial code and add the new initial code as following.

//xc = peak_pos(x_y_curve, &w, &y0, &A);
//w *= 0.85;
sort(x_y_curve);
smooth(x_y_curve);
y0 = yatxmin( x_y_curve );
w = 0.85 * fwhm( x_y_curve, y0 );
A = area( x_y_curve, y0 );
if ( A > 0 ) xc = xatymax( x_y_curve );
else xc = xatymin( x_y_curve );

4. Save the changes.

Now, you can try this changed Gauss function again. We are very sorry for the inconvenience.


Penn
Go to Top of Page

a.abc.b35

175 Posts

Posted - 07/05/2011 :  8:58:32 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks Penn..will try that ..

AB
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