1
$\begingroup$

I found this code:

function [z] = levy(n,m,beta)
% This function implements Levy's flight. 

% For more information see 
%'Multiobjective cuckoo search for design optimization Xin-She Yang, Suash Deb'. 

% Coded by Hemanth Manjunatha on Nov 13 2015.

% Input parameters
% n     -> Number of steps 
% m     -> Number of Dimensions 
% beta  -> Power law index  % Note: 1 < beta < 2

% Output 
% z     -> 'n' levy steps in 'm' dimension

    num = gamma(1+beta)*sin(pi*beta/2); % used for Numerator 

    den = gamma((1+beta)/2)*beta*2^((beta-1)/2); % used for Denominator

    sigma_u = (num/den)^(1/beta);% Standard deviation

    u = random('Normal',0,sigma_u^2,n,m); 

    v = random('Normal',0,1,n,m);

    z = u./(abs(v).^(1/beta));


end

The code above simulates Lévy flight, but I don't really understand why it really works or why it does it simulate a Lévy flight? I mean I don't see how the following distribution emerges from the algorithm above:

$$Pr(U>u) = \begin{cases} 1 &:\ u < 1,\\ u^{-D} &:\ u \ge 1. \end{cases}$$

If I run plot(levy(1000,1,1.5)) this is what I get:

enter image description here

Also the cumsum doesn't look like a Levy Flight:

enter image description here

$\endgroup$
  • $\begingroup$ Are you looking for an explanation what a Levy Flight is? $\endgroup$ – usεr11852 Feb 25 '18 at 0:27
  • $\begingroup$ @usεr11852 maybe an explanation how this code is related to any definition of Lévy flight. $\endgroup$ – 0x90 Feb 25 '18 at 1:02
  • 1
    $\begingroup$ Did you look at the paper referenced in the code? $\endgroup$ – Mark L. Stone Feb 25 '18 at 2:04
  • $\begingroup$ @MarkL.Stone the math is too advanced. $\endgroup$ – 0x90 Feb 26 '18 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.