Problem with Random data delay - Signal Processing,
1 次查看(过去 30 天)
显示 更早的评论
Dear all,
I need to generate random data using non-homogeneous Poisson and put it in the X-axis and generate another data using non-homogeneous Poisson but delay it with some time then calculate the delay time.. I understand the steps of doing this,, I generated different data but using Gaussian and I used cross correlation for estimating the time delay..and for delaying one of the signals I used zero-padding.. I know how the whole process should be and I understand from generating couple of files and asking questions here. But my problem now, from the code I've done so far for the non-homogeneous Poisson, I am not sure how to find the X and Y entries for the signal created because If I find the X and Y.. I can shift the other signal by zero-padding then use Cross correlation to find an estimate delay.. I don't know if the code I've done so far is wrong or something is missing!! Just to clarify the random data generated using non-homogeneous should be on the X-axis (Red data) and the estimated function for the data is kernel..I don't know if i generated the non-homogeneous Poisson correct because every time I run the data are in the same place and It should be random data(changing everytime I run)?!!
http://www.stat.sdu.dk/matstat/yuri-st505/w5slides1.pdf [The non-homogeneous algorithm in the last page ].
function test
lambdaMax=45;
T=50;
x=-2*pi:1/5:2*pi;
lambda =@(x)( sin(x)*(20+30));
S = Trial11(lambdaMax,lambda,T)
hold on
line(repmat(S,2,1),repmat([0;1*0.006],1,length(S)),'color','r' )
[xi,f]=ksdensity(S);
plot(f,xi,'color','blue');
end
function S = trial11(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
Any help and explanation will be highly appreciated ! Thanks all for your time, Susan
回答(1 个)
Daniel Shub
2011-9-14
Typically a Poisson process (homogenous or non-homogenous) produces a set of times at which event occurs. This is very different from a Gaussian process which produces a value at all times. With the Gaussian process you have "x" and "y" data, but with a Poisson process you only have "t" ((which you are calling S). You can create x and y from t. The easiest way would be to:
sr = 44.1e3; % A reasonable sample rate for audio applications
z = round(S*sr)+1; % Need to transform S from seconds to indices
x = 0:1/sr:T;
y = zeros(size(x));
y(z) = 1;
3 个评论
Daniel Shub
2011-9-14
The last line sets the values of y to be equal to 1 at the times at which the Poisson process indicated that events occurred. To best match your code you could use 0.006 instead of 1. I think ksdensity only works for things that are normal (or close to normal) so I would not use it here (but then again I have no idea what you are trying to do). To plot the results, you could use:
stem(x, y)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Waveform Generation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!