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
 Fitting with gamma 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
Estitxu Posted - 04/09/2013 : 06:11:45 AM
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
4   L A T E S T    R E P L I E S    (Newest First)
Estitxu Posted - 07/16/2013 : 09:06:23 AM
I'm sorry but I could not solve the problem... :(
kimi_young Posted - 07/16/2013 : 04:29:43 AM
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
Estitxu Posted - 04/30/2013 : 09:32:37 AM
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
Sam Fang Posted - 04/10/2013 : 11:33:57 PM
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

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