T O P I C R E V I E W |
friedman |
Posted - 09/30/2015 : 12:52:25 PM Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2015 Operating System:Mac with crossover
I want to define a NL fitting function that includes the digamma function. How do I do this? |
3 L A T E S T R E P L I E S (Newest First) |
friedman |
Posted - 10/02/2015 : 11:46:20 AM Here's my code:
What is wrong? It keeps saying "too many arguments passed to function." #pragma numlittype(push, TRUE) #pragma warning(error : 15618) #include <origin.h>
// Add your special include files here. // For example, if you want to fit with functions from the NAG library, // add the header file for the NAG functions here. #include <OC_nag8.h>
// Add code here for other Origin C functions that you want to define in this file, // and access in your fitting function.
// You can access C functions defined in other files, if those files are loaded and compiled // in your workspace, and the functions have been prototyped in a header file that you have // included above.
// You can access NLSF object methods and properties directly in your function code.
// You should follow C-language syntax in defining your function. // For instance, if your parameter name is P1, you cannot use p1 in your function code. // When using fractions, remember that integer division such as 1/2 is equal to 0, and not 0.5 // Use 0.5 or 1/2.0 to get the correct value.
// For more information and examples, please refer to the "User-Defined Fitting Function" // section of the Origin Help file.
//---------------------------------------------------------- // void _nlsflocalization( // Fit Parameter(s): double tp, double y0, // Independent Variable(s): double x, // Dependent Variable(s): double& y) { const double ta=1; const double tb=1; const double tc=1; // Beginning of editable part static NagError fail1; static NagError fail2; static NagError fail3; double part1 = tc*x/tp; double part2 = tc*x/(tp-2*ta); double part3 = tc*x/(tp+ta+tb); y= y0*(ln(part1) + s15aec(part1,0, &fail1) - ln(part2) - s15aec(part2,0, &fail2)-2*ln(part3)-2*s15aec(part3,0,&fail)); if(fail1.code !=NE_NOERROR) printf("%s\n",fail1.message); if(fail2.code !=NE_NOERROR) printf("%s\n",fail2.message); if(fail3.code !=NE_NOERROR) printf("%s\n",fail2.message); // End of editable part |
friedman |
Posted - 10/02/2015 : 11:23:42 AM That example is for integration. I want to fit to a function:
F(C*x/p)-F(C*x/(p-2*A))-2*F(C*x/(p+A+B))
Where F(z)=ln(z)+digamma(0.5+1/z) and A,B,C are constants, p is the fitting parameter, and x is the independent variable. I know I need to somehow use the NAG function s15aec.
I don't see how to do this given the example suggested. I don't know how to program in C whatsoever. I can only copy and paste the example, which doesn't really apply here. |
Hideo Fujii |
Posted - 10/01/2015 : 3:13:06 PM Hi friedman,
Origin includes NAG numerical library which contains polygamma function in the category of Approximations of Special Functions: http://www.nag.com/numeric/CL/nagdoc_cl09/html/S/sconts.html#s
You can define your user-defined fit function which calls a NAG function. You see the following tutorial to learn how to call a NAG function from your fit function definition: http://www.originlab.com/doc/Tutorials/Fitting-Integral-NAG
I hope the above information is helpful.
--Hideo Fujii OriginLab |
|
|