DSPRelated.com
Forums

A test for stationarity assumption

Started by shinchan75034 October 23, 2010
Hello DSP experts,
I would like to know whether or not a signal can be considered stationary.
I understand the textbook definition for stationarity, i.e., pdf of the
signal doesn't depend on time.  To me, the corollary of which is that if a
signal is stationary, then the variance of the signal is not a function of
time. I assume a random signal generated by Matlab is stationary. So I
wrote the Matlab code below. I ran it a few times and I almost always see a
drift in variance as time goes by. I Maybe this is not the right way to
test for stationarity of a signal? Or maybe I misunderstood the concept of
stationarity? Thank you for your input.


close all;
clear all;
signal = rand([300,1]);
signalzm = signal-mean(signal);
%After 100 timpoint, I feel it has sufficient data to calculate variance.
           for j = 100:1:300
           variance_vector = var(signalzm(1:j));
           
           holder(j-99, :) = variance_vector;
           
           end;
           
subplot(211); plot(signalzm);
subplot(212); plot(100:300, holder);

shinchan75034 wrote:

> Hello DSP experts, > I would like to know whether or not a signal can be considered stationary.
That is impossible.
> I understand the textbook definition for stationarity, i.e., pdf of the > signal doesn't depend on time.
You can only know (with some probablitity) that the signal does not seem to depend from time in a *given* particular way.
> To me, the corollary of which is that if a > signal is stationary, then the variance of the signal is not a function of > time. I assume a random signal generated by Matlab is stationary. So I > wrote the Matlab code below.
Matlabi Stupident.
> I ran it a few times and I almost always see a > drift in variance as time goes by.
> %After 100 timpoint, I feel it has sufficient data to calculate variance.
What makes you feel that? VLV
On Oct 24, 12:42=A0pm, "shinchan75034"
<shinchan75034@n_o_s_p_a_m.gmail.com> wrote:
> Hello DSP experts, > I would like to know whether or not a signal can be considered stationary=
.
> I understand the textbook definition for stationarity, i.e., pdf of the > signal doesn't depend on time. =A0To me, the corollary of which is that i=
f a
> signal is stationary, then the variance of the signal is not a function o=
f
> time. I assume a random signal generated by Matlab is stationary. So I > wrote the Matlab code below. I ran it a few times and I almost always see=
a
> drift in variance as time goes by. I Maybe this is not the right way to > test for stationarity of a signal? Or maybe I misunderstood the concept o=
f
> stationarity? Thank you for your input. > > close all; > clear all; > signal =3D rand([300,1]); > signalzm =3D signal-mean(signal); > %After 100 timpoint, I feel it has sufficient data to calculate variance. > =A0 =A0 =A0 =A0 =A0 =A0for j =3D 100:1:300 > =A0 =A0 =A0 =A0 =A0 =A0variance_vector =3D var(signalzm(1:j)); > > =A0 =A0 =A0 =A0 =A0 =A0holder(j-99, :) =3D variance_vector; > > =A0 =A0 =A0 =A0 =A0 =A0end; > > subplot(211); plot(signalzm); > subplot(212); plot(100:300, holder);
Yes, check that the basic statistics are not time-varing. Hardy
On 10/23/2010 04:42 PM, shinchan75034 wrote:
> Hello DSP experts, > I would like to know whether or not a signal can be considered stationary. > I understand the textbook definition for stationarity, i.e., pdf of the > signal doesn't depend on time. To me, the corollary of which is that if a > signal is stationary, then the variance of the signal is not a function of > time. I assume a random signal generated by Matlab is stationary. So I > wrote the Matlab code below. I ran it a few times and I almost always see a > drift in variance as time goes by. I Maybe this is not the right way to > test for stationarity of a signal? Or maybe I misunderstood the concept of > stationarity? Thank you for your input. > > > close all; > clear all; > signal = rand([300,1]); > signalzm = signal-mean(signal); > %After 100 timpoint, I feel it has sufficient data to calculate variance. > for j = 100:1:300 > variance_vector = var(signalzm(1:j)); > > holder(j-99, :) = variance_vector; > > end; > > subplot(211); plot(signalzm); > subplot(212); plot(100:300, holder);
You are measuring the variance of the first 100 samples, then the first 101 samples, then the first 102 samples, etc. Of _course_ the variance is going to drift with time, because your calculated variances are not independent of each other. You're seeing an artifact of your calculation process. Try getting yourself a much bigger sample -- 1000 points would still be small -- and measure the variance in independent blocks of 100. See if you see drift. See how much the variance changes. If you've got a good statistics textbook, there will be a discussion about the variance of samples of random processes, somewhere close to the "chi distribution". -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
Tim Wescott <tim@seemywebsite.com> writes:
> [...] > Try getting yourself a much bigger sample -- 1000 points would still > be small
Tim, what criteria do you use for this statement? Is it just experience, or is there some analytical basis? -- Randy Yates % "I met someone who looks alot like you, Digital Signal Labs % she does the things you do, mailto://yates@ieee.org % but she is an IBM." http://www.digitalsignallabs.com % 'Yours Truly, 2095', *Time*, ELO
On Oct 24, 9:33=A0am, Randy Yates <ya...@ieee.org> wrote:
> Tim Wescott <t...@seemywebsite.com> writes: > > [...] > > Try getting yourself a much bigger sample -- 1000 points would still > > be small > > Tim, what criteria do you use for this statement? Is it just > experience, or is there some analytical basis? > -- > Randy Yates =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0% "I met someone w=
ho looks alot like you,
> Digital Signal Labs =A0 =A0 =A0 =A0 =A0 =A0 =A0% =A0 =A0 =A0 =A0 =A0 =A0 =
she does the things you do,
> mailto://ya...@ieee.org =A0 =A0 =A0 =A0 =A0% =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 but she is an IBM."http://www.digitalsignallabs.com% =A0 =A0 = =A0 =A0'Yours Truly, 2095', *Time*, ELO =A0 See 'Law of large numbers'
On 10/24/2010 09:33 AM, Randy Yates wrote:
> Tim Wescott<tim@seemywebsite.com> writes: >> [...] >> Try getting yourself a much bigger sample -- 1000 points would still >> be small > > Tim, what criteria do you use for this statement? Is it just > experience, or is there some analytical basis?
WAG, based on experience. But I like Brian's answer better -- it makes me sound wise. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
On 10/24/2010 09:33 AM, Randy Yates wrote:
> Tim Wescott<tim@seemywebsite.com> writes: >> [...] >> Try getting yourself a much bigger sample -- 1000 points would still >> be small > > Tim, what criteria do you use for this statement? Is it just > experience, or is there some analytical basis?
The way to know for sure how many samples you need is to find the probability distribution of the variance estimate that you'll make from your random process, for sample vectors of various lengths. For a normal process, IIRC, it's the chi distribution, although I'm officially declaring myself too dang lazy to dig out my statistics book for a check. It does take a surprisingly long sample to get a good handle on variance, but I can only remember the surprise -- not the length of the sample. -- Tim Wescott Wescott Design Services http://www.wescottdesign.com Do you need to implement control loops in software? "Applied Control Theory for Embedded Systems" was written for you. See details at http://www.wescottdesign.com/actfes/actfes.html
Bryan <bryan.paul@gmail.com> writes:

> On Oct 24, 9:33&nbsp;am, Randy Yates <ya...@ieee.org> wrote: >> Tim Wescott <t...@seemywebsite.com> writes: >> > [...] >> > Try getting yourself a much bigger sample -- 1000 points would still >> > be small >> >> Tim, what criteria do you use for this statement? Is it just >> experience, or is there some analytical basis? >> -- >> Randy Yates &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;% "I met someone who looks alot like you, >> Digital Signal Labs &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;% &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; she does the things you do, >> mailto://ya...@ieee.org &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;% &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; but she is an IBM."http://www.digitalsignallabs.com% &nbsp; &nbsp; &nbsp; &nbsp;'Yours Truly, 2095', *Time*, ELO &nbsp; > > See 'Law of large numbers'
Yeah, but how large is "large?" -- Randy Yates % "Maybe one day I'll feel her cold embrace, Digital Signal Labs % and kiss her interface, mailto://yates@ieee.org % til then, I'll leave her alone." http://www.digitalsignallabs.com % 'Yours Truly, 2095', *Time*, ELO
On Sun, 24 Oct 2010 17:20:33 -0400, Randy Yates <yates@ieee.org>
wrote:

>Bryan <bryan.paul@gmail.com> writes: > >> On Oct 24, 9:33&#4294967295;am, Randy Yates <ya...@ieee.org> wrote: >>> Tim Wescott <t...@seemywebsite.com> writes: >>> > [...] >>> > Try getting yourself a much bigger sample -- 1000 points would still >>> > be small >>> >>> Tim, what criteria do you use for this statement? Is it just >>> experience, or is there some analytical basis? >>> -- >>> Randy Yates &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295;% "I met someone who looks alot like you, >>> Digital Signal Labs &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295;% &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; she does the things you do, >>> mailto://ya...@ieee.org &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295;% &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; &#4294967295; but she is an IBM."http://www.digitalsignallabs.com% &#4294967295; &#4294967295; &#4294967295; &#4294967295;'Yours Truly, 2095', *Time*, ELO &#4294967295; >> >> See 'Law of large numbers' > >Yeah, but how large is "large?"
The "larger", the "better" -- Muzaffer Kal DSPIA INC. ASIC/FPGA Design Services http://www.dspia.com