Problem with Random data delay - Signal Processing,

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

7 Comments

@Susan: You've posted two functions. Which one causes the problems? I'd expect that the "test" function calls the "nonhomogeneousPossion" function, but it doesn't. It calls "Trial11" instead, but you did not post the corresponding code...
A usual cause for getting the same reply for random data is a seeding of the random number generator.
Thanks Jan for your reply, I corrected it.. the non-homogeneous is the trial11 and test is causing the trouble.. the trial function is where the non-homogeneous data needs to be generated.
If I run your code (after some modification to get it compatible to 2009a), I get different values in each run. So waht is the exact problem?
Ok-It just looked the same to me.. are you talking about the data plotted in Red in the X-axis? My main question was because the data generated is stored in S, I am not sure how to get the point X and Y? because I want to create another signal but zero-padding the first few entries and then measure the degree of similarity using Cross correlation.. I am meant to have the data generated (It is done) Find an estimate function using Kernel(It is done) and NOW create another signal similar to this but first few entries is zero-padded?
Sorry, then I did and do not understand the question. Is your question like this: "How to insert some zeros at the beginning of a 1D signal"? Then posting the complicated code would have been too confusing.
Yeah but I know how to do the zero-padding if I have X and Y.. but how can it be done if my random data generated is in S (no X and Y)
Yeah it is 1D signal

Sign in to comment.

Answers (1)

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 Comments

Thanks Daniel, can you tell me what is the last line y(z)=1. Now that you explained to me it generates only t and the way to get a sample rate with X and Y..
For my code I have S(non-homogeneous Poisson) plotted in the X-axis. I estimated the kernel on top of it ,. Now I want to plot the second signal which should be S but lagged then estimate kernel. Is that mean I need to use your way above and generate a sample rate from S??
function test
lambdaMax=45;
T=50;
x=-2*pi:1/5:2*pi;
lambda =@(x)( sin(x)*(20+30));
S = Trial11(lambdaMax,lambda,T)
subplot(2,1,1)
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');
subplot(2,1,2)
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;
line(repmat(z,2,1),repmat([0;1*0.006],1,length(z)),'color','r' )
[xi,f]=ksdensity(z);
plot(f,xi,'color','blue');
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)
I am trying to generate non-homogeneous data and plot it in the X-axis basically to show the time the data arrived then estimate a function for the arrived data and in my case i used Ksdensity(don't know if there are anyother ones) onces its estimated i will be able to generate another data but delayed with sometime and estimate the function for that one too !

Sign in to comment.

Asked:

on 14 Sep 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!