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
 Fitting with gamma function
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Estitxu

13 Posts

Posted - 04/09/2013 :  06:11:45 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi,

I have Origin 8 and I'm trying to fit some data with the function "digamma". This is the derivative of the logarithm of gamma: d/dx(ln(gamma(x))).
I've seen that the function log_gamma(x) is defined in Origin, therefore I constructed the digamma function with the derivative the following way:
y =((log_gamma(x+h)-log_gamma(x)))/h
where h=0.00005 is the step size for the derivation

In reality, my function is a bit more complicated than just digamma(x), is a sum of 3 digammas with different variables. My function then is defined the following way:

//
void _nlsfMirenEstiWAL(
// Fit Parameter(s):
double Tso, double Ti,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double A=1.962E-6; // e^2/2Pi^2 h
double B=1.419E-14; // hbarra/4eD, D=1/rho*e^2*DOS, rho_Au=2.95E-8,DOS_Au=1.14E47
double T0=2.037E-14; // m/n e^2 rho, n_Au=5.9E28, rho_Au=2.95E-8
double h=0.00005; //step size for derivative
y=(-A*(((log_gamma(0.5+B*(1/T0+1/Tso)/abs(x)+h)-log_gamma(0.5+B*(1/T0+1/Tso)/abs(x))))/h-1.5*((log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x)+h)-log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x))))/h+0.5*((log_gamma(0.5+B/(Ti*abs(x))+h)-log_gamma(0.5+B/(Ti*abs(x)))))/h))
// End of editable part
}

I compile it, that part is OK, I also simulate it and it takes a shape similar to my data, but when I try to fit it that's impossible. I wanna obtain Tso and Ti, I insert some initial values, and when trying to fit, the only thing I get is a representation of the function with those initial parameters (like in the simulation), but the parameters didn't change and they do not adjust to the equation. I tried fixing one of the parameters, to see if it was possible to fit just a single parameter, but the same happened.

Thanks in advance,

Estitxu

Sam Fang

291 Posts

Posted - 04/10/2013 :  11:33:57 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Maybe you need adjust the initial parameters to fit your data. Some fitting functions are sensitive to the initial values. If the problem still exists, you can send your data to us, and we can try it.

To send file to us, click Send File to Tech support button on the top right of the forum.

BTW Origin provides a built-in function for the derivative of the logarithm of gamma. You can use it directly.
------------------
real_polygamma( x, 0 )

------------------



Sam
OriginLab Technical Services

Edited by - Sam Fang on 04/10/2013 11:35:13 PM
Go to Top of Page

Estitxu

13 Posts

Posted - 04/30/2013 :  09:32:37 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

I try with the real_polygamma(x,0) function and I keep having the same problem.

So I'm trying to use these two functions to fit my data:

void _nlsfMirenEstiWALpsi(
// Fit Parameter(s):
double Tso, double Ti,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double A=1.962E-6; // e^2/2Pi^2 h
double B=1.419E-14; // hbarra/4eD, D=1/rho*e^2*DOS, rho_Au=2.95E-8,DOS_Au=1.14E47
double T0=2.037E-14; // m/n e^2 rho, n_Au=5.9E28, rho_Au=2.95E-8
double h=0.00005;
y=-A*(real_polygamma(0.5+B*(1/T0+1/Tso)/abs(x),0)-1.5*real_polygamma(0.5+B*(1.333/Tso+1/Ti)/abs(x),0)+0.5*real_polygamma(0.5+B/(Ti*abs(x)),0))

//y=(-A*(((log_gamma(0.5+B*(1/T0+1/Tso)/abs(x)+h)-log_gamma(0.5+B*(1/T0+1/Tso)/abs(x))))/h-1.5*((log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x)+h)-log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x))))/h+0.5*((log_gamma(0.5+B/(Ti*abs(x))+h)-log_gamma(0.5+B/(Ti*abs(x)))))/h))
//y =((log_gamma(x+h)-log_gamma(x)))/h
// End of editable part
}




or






void _nlsfMirenEstiWALDeltaPsi(
// Fit Parameter(s):
double Tso, double Ti,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double A=1.962E-6; // e^2/2Pi^2 h
double B=1.419E-14; // hbarra/4eD, D=1/rho*e^2*DOS, rho_Au=2.95E-8,DOS_Au=1.14E47
double T0=2.037E-14; // m/n e^2 rho, n_Au=5.9E28, rho_Au=2.95E-8
double h=0.00005;

y=A*(real_polygamma(0.5+B*(1/T0+1/Tso)/abs(x),0)-1.5*real_polygamma(0.5+B*(1.333/Tso+1/Ti)/abs(x),0)+0.5*real_polygamma(0.5+B/(Ti*abs(x)),0))-A*(real_polygamma(0.5+B*(1/T0+1/Tso)/abs(3),0)-1.5*real_polygamma(0.5+B*(1.333/Tso+1/Ti)/abs(3),0)+0.5*real_polygamma(0.5+B/(Ti*abs(3)),0))

//y=A*(((log_gamma(0.5+B*(1/T0+1/Tso)/abs(x)+h)-log_gamma(0.5+B*(1/T0+1/Tso)/abs(x))))/h-1.5*((log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x)+h)-log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x))))/h+0.5*((log_gamma(0.5+B/(Ti*abs(x))+h)-log_gamma(0.5+B/(Ti*abs(x)))))/h)-A*(((log_gamma(0.5+B*(1/T0+1/Tso)/abs(3)+h)-log_gamma(0.5+B*(1/T0+1/Tso)/abs(3))))/h-1.5*((log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(3)+h)-log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(3))))/h+0.5*((log_gamma(0.5+B/(Ti*abs(3))+h)-log_gamma(0.5+B/(Ti*abs(3)))))/h)
//y =((log_gamma(x+h)-log_gamma(x)))/h
// End of editable part
}



The initial parameters I'm inserting are close to the ones that are logical to obtain: Tso=1e-12 and Ti=1e-9. And as I told you, instead of fitting the data, I just get a representation of the function with those inserted parameters.

I'm sending you the data that want to fit via the "Send file to Tech Support" button.

Thanks a lot,

Estitxu
Go to Top of Page

kimi_young

China
1 Posts

Posted - 07/16/2013 :  04:29:43 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
quote:
Originally posted by Estitxu

Hi,

I try with the real_polygamma(x,0) function and I keep having the same problem.

So I'm trying to use these two functions to fit my data:

void _nlsfMirenEstiWALpsi(
// Fit Parameter(s):
double Tso, double Ti,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double A=1.962E-6; // e^2/2Pi^2 h
double B=1.419E-14; // hbarra/4eD, D=1/rho*e^2*DOS, rho_Au=2.95E-8,DOS_Au=1.14E47
double T0=2.037E-14; // m/n e^2 rho, n_Au=5.9E28, rho_Au=2.95E-8
double h=0.00005;
y=-A*(real_polygamma(0.5+B*(1/T0+1/Tso)/abs(x),0)-1.5*real_polygamma(0.5+B*(1.333/Tso+1/Ti)/abs(x),0)+0.5*real_polygamma(0.5+B/(Ti*abs(x)),0))

//y=(-A*(((log_gamma(0.5+B*(1/T0+1/Tso)/abs(x)+h)-log_gamma(0.5+B*(1/T0+1/Tso)/abs(x))))/h-1.5*((log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x)+h)-log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x))))/h+0.5*((log_gamma(0.5+B/(Ti*abs(x))+h)-log_gamma(0.5+B/(Ti*abs(x)))))/h))
//y =((log_gamma(x+h)-log_gamma(x)))/h
// End of editable part
}




or






void _nlsfMirenEstiWALDeltaPsi(
// Fit Parameter(s):
double Tso, double Ti,
// Independent Variable(s):
double x,
// Dependent Variable(s):
double& y)
{
// Beginning of editable part
double A=1.962E-6; // e^2/2Pi^2 h
double B=1.419E-14; // hbarra/4eD, D=1/rho*e^2*DOS, rho_Au=2.95E-8,DOS_Au=1.14E47
double T0=2.037E-14; // m/n e^2 rho, n_Au=5.9E28, rho_Au=2.95E-8
double h=0.00005;

y=A*(real_polygamma(0.5+B*(1/T0+1/Tso)/abs(x),0)-1.5*real_polygamma(0.5+B*(1.333/Tso+1/Ti)/abs(x),0)+0.5*real_polygamma(0.5+B/(Ti*abs(x)),0))-A*(real_polygamma(0.5+B*(1/T0+1/Tso)/abs(3),0)-1.5*real_polygamma(0.5+B*(1.333/Tso+1/Ti)/abs(3),0)+0.5*real_polygamma(0.5+B/(Ti*abs(3)),0))

//y=A*(((log_gamma(0.5+B*(1/T0+1/Tso)/abs(x)+h)-log_gamma(0.5+B*(1/T0+1/Tso)/abs(x))))/h-1.5*((log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x)+h)-log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(x))))/h+0.5*((log_gamma(0.5+B/(Ti*abs(x))+h)-log_gamma(0.5+B/(Ti*abs(x)))))/h)-A*(((log_gamma(0.5+B*(1/T0+1/Tso)/abs(3)+h)-log_gamma(0.5+B*(1/T0+1/Tso)/abs(3))))/h-1.5*((log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(3)+h)-log_gamma(0.5+B*(1.333/Tso+1/Ti)/abs(3))))/h+0.5*((log_gamma(0.5+B/(Ti*abs(3))+h)-log_gamma(0.5+B/(Ti*abs(3)))))/h)
//y =((log_gamma(x+h)-log_gamma(x)))/h
// End of editable part
}



The initial parameters I'm inserting are close to the ones that are logical to obtain: Tso=1e-12 and Ti=1e-9. And as I told you, instead of fitting the data, I just get a representation of the function with those inserted parameters.

I'm sending you the data that want to fit via the "Send file to Tech Support" button.

Thanks a lot,

Estitxu


hi
Recently, I'm also trying to fit some data with the function "digamma". As I'm not familiar with the User-Defined Fitting Functions,especially the complex one,what you have written here helps me a lot.
However, have you solved your problem here? And what's your last defined function? thank you very much
Go to Top of Page

Estitxu

13 Posts

Posted - 07/16/2013 :  09:06:23 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I'm sorry but I could not solve the problem... :(
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