Frage

I have been looking around for a while on fitting Levy Distributions to a histogram to no avail. I am hoping to test out how a Levy Flight distribution would look on the data regardless of whether it truly is the right fit for our data type. Since I am rather new at PDFs and fitting my own PDFS aside from the distfittool GUI in matlab, I am a bit unaware of what I need to do to properly do this.

So currently, my data is a 208x1 vector, 208 points represents different speeds for 208 distinct objects. Speeds were calculated just via overall distance per time.

Now, currently I took the function that describes the Levy flight from: http://reference.wolfram.com/mathematica/ref/LevyDistribution.html (Out[3])

And I used the following code to try it out:

load('Speeds.mat')
modelFun = @(p,x) (exp(-p(1)./(2.*(x-p(2)))).*(p(1)./(x-p(2))).^3/2)./(sqrt(2.*pi).*p(1));
startingVals = [1 1];
coefEsts = nlinfit(LBSpeed,modelFun,startingVals);

I am completely aware that my lack of familiarity with the Levy flight distribution is the root of why I am not even sure whether that is the proper function to use for the distribution, nor the arguments I need to pass to it to properly do this. If anyone could give me a bit more insight, I'd greatly appreciate it.

War es hilfreich?

Lösung

I have seen similar questions to this problem with no answers, so after getting help from a colleague I wanted to post the solution

The other thing that was changed from my original question, is that it became piecewise to better satisfy the reference of the levy flight equation I posted myself. The starting vals I chose were arbitrary.

load('Speeds.mat')
[N,X] = hist(Speed,20);
Y = N/(sum(N))/diff(X(1:2));

%Get best parameters
modelFun = @(p,x) (x>p(2)).*(exp(-p(1)./(2.*(x-p(2)))).*(p(1)./(x-p(2))).^(3/2))./(sqrt(2.*pi).*p(1));
startingVals = [1,1];
coefEsts = nlinfit(X,Y,modelFun, startingVals);

%Visualize fit
bar(X,Y);
hold on;
model_eval = modelFun(coefEsts,X);
plot(X,model_eval,'r','LineWidth',2);

I wasn't aware of how to fit histograms in the first place, so hope this helps someone new to this!

Andere Tipps

you can find fitting routine in Matlab code on this website

http://math.bu.edu/people/mveillet/html/alphastablepub.html

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top