orzi1980
Computer
- Jul 31, 2005
- 1
Hi all
I have to analyze the waiting time distribution between trades using the Mittag Leffler function.
I simply need to fit 2 parameters of the Mittag Leffler function (see end of 2nd page in this paper:) using the nonlinear fit function (nlfit) embedded in Matlab. I wrote a code that seems
to be reasonable to a roocky like me, but I realised that the MittagLeffler function I estimate converges only in a few cases. In other words I would
like to know if it is possible to write a more consistent code so to obtain
reasonable estimations in almost all the cases.
What I have to do is quite simple: using the function "empirical cdf" (ecdf)
I plot the empirical data (waiting time betwwen trades) in a loglog graph.
Then I try to fit the data to the Mittag Leffler function (and 2 other functions,
but I have more problems with the ML).
I would really appreciate your help expecially because it is summer and I
am sure you have many other funnier things to do!
I hope to hear from you soon since it it very urgent!
I can meet in a chat or I can give you my phone number if you want.
Federico
This is the code I wrote for the Mittag Leffler:
function y = mitlef (parametri, tau) %mittag
tau0 = parametri(1);
beta = parametri(2);
if beta < 0
printf('beta!!!!\n');
end
Sum = 0;
N = 100;
for n = 0:N
yn = (-1)^n * ((tau ./ tau0).^(beta*n)) ./ gamma(1 + beta*n);
Sum = Sum + yn;
end
y = Sum;
%loglog(tau,y); (I wanted to see how the function diverges)
To plot the empirical cdf of the data I need I wrote:
[f, riba_x] = ecdf(emp_data);
riba_y = 1 - f;
hf = figure(1);
loglog(riba_x, riba_y, 'ob')
title('GM') %
set(hf, 'NumberTitle', 'off')
set(hf, 'Name', 'window')
hold on
Then, to fit the ML to the data I wrote this code:
% mittag leffler %
p0 = [4 1]'; %initial parameter values
p = nlinfit (riba_x, riba_y, @mitlef, p0) %non linear fit
fit_y = mitlef(p, riba_x);
plot(riba_x, fit_y, '- .r')
I have to analyze the waiting time distribution between trades using the Mittag Leffler function.
I simply need to fit 2 parameters of the Mittag Leffler function (see end of 2nd page in this paper:) using the nonlinear fit function (nlfit) embedded in Matlab. I wrote a code that seems
to be reasonable to a roocky like me, but I realised that the MittagLeffler function I estimate converges only in a few cases. In other words I would
like to know if it is possible to write a more consistent code so to obtain
reasonable estimations in almost all the cases.
What I have to do is quite simple: using the function "empirical cdf" (ecdf)
I plot the empirical data (waiting time betwwen trades) in a loglog graph.
Then I try to fit the data to the Mittag Leffler function (and 2 other functions,
but I have more problems with the ML).
I would really appreciate your help expecially because it is summer and I
am sure you have many other funnier things to do!
I hope to hear from you soon since it it very urgent!
I can meet in a chat or I can give you my phone number if you want.
Federico
This is the code I wrote for the Mittag Leffler:
function y = mitlef (parametri, tau) %mittag
tau0 = parametri(1);
beta = parametri(2);
if beta < 0
printf('beta!!!!\n');
end
Sum = 0;
N = 100;
for n = 0:N
yn = (-1)^n * ((tau ./ tau0).^(beta*n)) ./ gamma(1 + beta*n);
Sum = Sum + yn;
end
y = Sum;
%loglog(tau,y); (I wanted to see how the function diverges)
To plot the empirical cdf of the data I need I wrote:
[f, riba_x] = ecdf(emp_data);
riba_y = 1 - f;
hf = figure(1);
loglog(riba_x, riba_y, 'ob')
title('GM') %
set(hf, 'NumberTitle', 'off')
set(hf, 'Name', 'window')
hold on
Then, to fit the ML to the data I wrote this code:
% mittag leffler %
p0 = [4 1]'; %initial parameter values
p = nlinfit (riba_x, riba_y, @mitlef, p0) %non linear fit
fit_y = mitlef(p, riba_x);
plot(riba_x, fit_y, '- .r')