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
 All Forums
 Origin Forum
 Origin Forum
 Data fitting with double integral function

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
SLee Posted - 09/14/2017 : 10:46:57 PM
I have tried to fit the data with double integral function. Double integral function includes parameters n, c, and D. And the data set what I have is a function of x.
Thus, I wrote down Origin C to call a NAG integrator as below. But when I compile this, the error messages appears.

C:\...\_nlfNewfunction.fit(50) :Error, cannot convert argument in function call
C:\...\_nlfNewfunction.fit(50) :Error, general compile error
C:\...\_nlfNewfunction.fit(19) :Error, error(s) found in compiling function multid_quad_monte_carlo

This is my first time to configure double integral function, so I'm not sure what is the problem in my script. I attach the script below. Could you guys help me?



#pragma numlittype(push, TRUE)
#pragma numlittype(push, TRUE)
#pragma warning(error : 15618)
#include <Origin.h>
#include <OC_nag.h> 

#define MAXCLS 20000   //maximum number of integrand evaluations to be allowed

static double NAG_CALL f(Integer ndim, double z[], double x, double n, double c, double D, Nag_User *comm)  
{
  return n-n/(pi*x*8.617E-5)*(1/(1+exp(sqrt(z[1]^2+(D*tanh(1.82*(1.082*(c/x-1))^0.51)*cos(2*z[0]))^2)/(8.617E-5*x))))*(1-1/(1+exp(sqrt(z[1]^2+(D*tanh(1.82*(1.082*(c/x-1))^0.51)*cos(2*z[0]))^2)/(8.617E-5*x)))); //define the function formula
}

int multid_quad_monte_carlo()
{
	Integer exit_status = 0, k, maxcls = MAXCLS, mincls;
	Integer ndim =2;  // the number of dimensions of the integral
	
	NagError fail;
	Nag_MCMethod method;
	Nag_Start cont;
	Nag_User comm;
	double a[2], b[2], acc, *comm_arr, eps, finest;		
	comm_arr=NULL;
	
	if (ndim < 1){
		printf("Invalid ndim.\n");
		exit_status = -1;
		return exit_status;   
    }	
	a[0] = 0.0;   // the lower limits of integration
	b[0] = 2*pi;   // the upper limits of integration
	a[1] = 0.0;   // the lower limits of integration
	b[1] = 10000;   // the upper limits of integration
	
	eps = 0.01;  //the relative accuracy required
	mincls = 1000; //minimum number of integrand evaluations to be allowed
	method = Nag_ManyIterations;
	cont = Nag_Cold;
	
       /* nag_multid_quad_monte_carlo_1 (d01xbc).
	* Multi-dimensional quadrature, using Monte Carlo method,
	* thread-safe
	*/	
nag_multid_quad_monte_carlo_1(ndim, f, method, cont, a, b, &mincls, maxcls,eps, &finest, &acc, &comm_arr, &comm, &fail);

if (fail.code == NE_NOERROR || fail.code == NE_QUAD_MAX_INTEGRAND_EVAL){
	if (fail.code == NE_QUAD_MAX_INTEGRAND_EVAL){
		printf("Error from nag_multid_quad_monte_carlo_1 (d01xbc).\n%s\n",fail.message);
		exit_status = 2;
	}
	//output the calculation results
	printf("Requested accuracy = %7.2e\n", eps);
	printf("Estimated value = %7.5f\n", finest);
	printf("Estimated accuracy = %7.2e\n", acc);
	printf("Number of evaluations = %6d\n", mincls);	
}
else{
	printf("Error from nag_multid_quad_monte_carlo_1 (d01xbc).\n%s\n",fail.message);
	exit_status = 1;
}
/* Free memory allocated internally */
if (comm_arr) 
	NAG_FREE(comm_arr);

return exit_status;
}

//----------------------------------------------------------
// 
void _nlsfNewfunction(
// Fit Parameter(s):
double A,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
	// Beginning of editable part
	y = x + A
	// End of editable part
}
1   L A T E S T    R E P L I E S    (Newest First)
yuki_wu Posted - 09/15/2017 : 04:28:03 AM
Hi,

We have a tutorial about fitting with integral using NAG library that may help you to learn this knowledge base item:
http://www.originlab.com/doc/Tutorials/Fitting-Integral-NAG

Also, we have a quick help that has a hint about double integral fitting function:
http://www.originlab.com/doc/Quick-Help/Summation-DoubleIntegral-Func

Hope it helps.

Regards,
Yuki
OriginLab

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000