I am trying to learn about the signals and wave for awhile now, It worked at the beggining but when I added few lines I get now curved line, I know it meant to be easy but not sure whats wrong .. I am using possion distribution !
here is my code..
function S = trial(lambdaMax,lambda,T)t = 0;I = 0;S = []; u = rand;t = t - log(u)/lambdaMax; while t < T u = rand; if (u <= lambda(t)/lambdaMax) I = I+1; S(I) = t; end u = rand; t = t - log(u)/lambdaMax;end
this is the script to run it,,
lambdaMax=50;T=1;lambda =@(x) lambdaMax * sin(x); S = trial(lambdaMax,lambda,T);figurehold onplot(S,lambda(S),'*')xlabel('t')ylabel ('sin(x)')
Best Answer