```On Jul 6, 12:53 am, "pa1kumar" <pavan352...@yahoo.com> wrote:
> Hi,
>
> I am trying to generate a random binary white noise signal such that when
> we take the auto spectrum of the signal it should roll of at 2Hz. I tried
> to do that by PWM but wasn't close. I was wondering if there is any better
> way to do this?
>
> I want to use this signal as an input in other software where the time is
> taken as a default milliseconds(ms) and the time step is 0.01ms. Is there
> a way to make my output in matlab compatible with the other software.
>
> Any help regarding this would be great.
>
> Thanks
> Pavan

Just pass white noise through a filter with the desired cut-off. It's
then coloured noise but white up to the passband freq.

```
```Randy Yates wrote:
> Tim Wescott <tim@seemywebsite.com> writes:
>
>> Randy Yates wrote:
>>> julius <juliusk@gmail.com> writes:
>>>> [...]
>>>> Strictly speaking, it is not "white".
>>> A digital signal can never be white anyway...
>> In a sampled-time system if each sample is independent from all the
>> rest and the mean is zero, then the power spectral density of the
>> sampled-time signal will be flat.
>
> It will be flat from -pi to +pi. That's not "flat to infinity."

Yup.  That's probably why I said "flat", not "flat to infinity".  You
say later in your post that the output of a discrete-time Fourier
transform is only defined from -pi to +pi -- thus, a signal as I have
described is flat over the entire range of valid frequencies of the
analysis -- you can't get any flatter than that.
>
>> Further, if your output is in the form of a train of dirac impulses
>> taking on the weighting of the sampled signals then the spectrum in
>> continuous time will be flat, also.
>
> Wow! I think you just crossed a couple of mathematically dangerous
> lines.

Probably.  It's fun, and safer than drinking while skateboarding.
>
> First of all, a "signal" consisting of weighted Dirac delta functions
> is not transformable since it has infinite energy.

Neither is purely white noise, for the same reasons.  Continuous-time
white noise is a convenient mathematical fiction.  So are Dirac delta
functionals.  Why admit the one and not the other?
>
> Second (and related), the spectrum of a random signal is not defined
> by taking the Fourier transform of the signal directly, but rather by
> taking a) the continuous-time Fourier transform of the continuous-time
> autocorrelation function if the random signal is continuous, or b) the
> discrete-time Fourier transform of the discrete-time autocorrelation
> function if the random signal is discrete. (And assumed wide-sense
> stationary in either case.)

If you don't like the Dirac delta functional your analysis will choke
pretty quickly when you try to find the autocorrelation function of
white noise.

One runs into difficulties with analyzing the signal, but they can be
resolved if you hold your mouth right.  Of course the fact that the
signal is sampled throws a wrench into the works if you're not careful,
but it can be overcome.  I think you'll find that if you represent the
impulses as rectangles with area = 1, that are parameterized for width,
you can the analysis then take the limit as the width goes to zero --
you'll find that the spectrum goes to white as expected.

If you're more adventurous, you can just extend the definition of the
sampling property of a Delta functional to include generating a
functional -- then it all works in one step.

I don't think you have to assume wide-sense stationarity, but if you
must just consider that you don't know the phase of the sample clock,
and refuse to find out -- then your signal (although odd) is WSS.
>
> Since, in the case of a discrete signal, the result of the
> discrete-time Fourier transform is only defined from -pi to +pi (or
> -Fs/2 to +Fs/2, depending on how it's defined), you can't talk about
> what's outside that range.

That depends on how you model your signal.  If you model the signal as a
series of numbers, then you are constrained to the discrete-time Fourier
transform but you have to take aliasing into account in your
reconstruction (which is, in this case, by generating
equivalent-strength delta functionals).  If you model the signal, as is
often done, as a sequence of delta functionals then you don't do the
discrete-time Fourier transform on it -- you do a continuous-time
Fourier transform, whose result _is_ defined over all frequencies.
>
>> I think it's entirely fair to describe such a signal as "white", as
>> long as you make sure folks know that it's in sampled time.
>
> If you looked at the analog output of a digital signal with independent
> samples, I'd expect you'd see something that was flat from DC to Fs/2.

I'd expect I'd see something that diminished as sin(pi * f * Ts)/f, at
least if the signal is just going to a normal DAC that acts as a
zero-order hold.

> That isn't "white" as I understand the term white since, for one thing,
> it's a finite-power signal.

Well, that's why I was trying to define what "white" means in sampled time!

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```Randy Yates wrote:

> Tim Wescott <tim@seemywebsite.com> writes:

(snip)

>>In a sampled-time system if each sample is independent from all the
>>rest and the mean is zero, then the power spectral density of the
>>sampled-time signal will be flat.

(snip)

>>Further, if your output is in the form of a train of dirac impulses
>>taking on the weighting of the sampled signals then the spectrum in
>>continuous time will be flat, also.

> Wow! I think you just crossed a couple of mathematically dangerous
> lines.

> First of all, a "signal" consisting of weighted Dirac delta functions
> is not transformable since it has infinite energy.

It was previously decided that white noise has infinite
energy, so it seems the right direction.

> Second (and related), the spectrum of a random signal is not defined
> by taking the Fourier transform of the signal directly, but rather by
> taking a) the continuous-time Fourier transform of the continuous-time
> autocorrelation function if the random signal is continuous, or b) the
> discrete-time Fourier transform of the discrete-time autocorrelation
> function if the random signal is discrete. (And assumed wide-sense
> stationary in either case.)

My interpretation is that he was taking a signal that was white
over the given bandwidth (0 to Fs/2) and aliasing to infinity.

That isn't quite the same as white, since it will have correlations
that it shouldn't otherwise have, but I would agree that under
spectral analysis it should look white.

-- glen

```
```Randy Yates wrote:
> julius <juliusk@gmail.com> writes:
>> [...]
>> Strictly speaking, it is not "white".
>
> A digital signal can never be white anyway...

A digital signal has limited bandwidth, but a signal can be flat (or
not) over the bandwidth it has. If "white" is taken to mean infinite
bandwidth rather that the bandwidth of interest, then there can be no
white light.

Jerry
--
Engineering is the art of making what you want from things you can get.
&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;&macr;
```
```"pa1kumar" <pavan352004@yahoo.com> writes:

> I am sorry guys that i was not that clear with my question. So the
> spectrum i want for the binary signal is that it should be as flat as
> possible until the 2Hz and roll off at 2HZ. I think i cant say it entirely
> as white but i want this kind of a binary signal.

That's easy - generate a series of independent samples and run them through
a filter of the desired shape. The hard part is specifying and designing
the filter.
--
%  Randy Yates                  % "My Shangri-la has gone away, fading like
%% Fuquay-Varina, NC            %  the Beatles on 'Hey Jude'"
%%% 919-577-9882                %
%%%% <yates@ieee.org>           % 'Shangri-La', *A New World Record*, ELO
```
```Tim Wescott <tim@seemywebsite.com> writes:

> Randy Yates wrote:
>> julius <juliusk@gmail.com> writes:
>>> [...]
>>> Strictly speaking, it is not "white".
>> A digital signal can never be white anyway...
>
> In a sampled-time system if each sample is independent from all the
> rest and the mean is zero, then the power spectral density of the
> sampled-time signal will be flat.

It will be flat from -pi to +pi. That's not "flat to infinity."

> Further, if your output is in the form of a train of dirac impulses
> taking on the weighting of the sampled signals then the spectrum in
> continuous time will be flat, also.

Wow! I think you just crossed a couple of mathematically dangerous
lines.

First of all, a "signal" consisting of weighted Dirac delta functions
is not transformable since it has infinite energy.

Second (and related), the spectrum of a random signal is not defined
by taking the Fourier transform of the signal directly, but rather by
taking a) the continuous-time Fourier transform of the continuous-time
autocorrelation function if the random signal is continuous, or b) the
discrete-time Fourier transform of the discrete-time autocorrelation
function if the random signal is discrete. (And assumed wide-sense
stationary in either case.)

Since, in the case of a discrete signal, the result of the
discrete-time Fourier transform is only defined from -pi to +pi (or
-Fs/2 to +Fs/2, depending on how it's defined), you can't talk about
what's outside that range.

> I think it's entirely fair to describe such a signal as "white", as
> long as you make sure folks know that it's in sampled time.

If you looked at the analog output of a digital signal with independent
samples, I'd expect you'd see something that was flat from DC to Fs/2.
That isn't "white" as I understand the term white since, for one thing,
it's a finite-power signal.
--
%  Randy Yates                  % "And all that I can do
%% Fuquay-Varina, NC            %  is say I'm sorry,
%%% 919-577-9882                %  that's the way it goes..."
%%%% <yates@ieee.org>           % Getting To The Point', *Balance of Power*, ELO
```
```>Randy Yates wrote:
>> julius <juliusk@gmail.com> writes:
>>> [...]
>>> Strictly speaking, it is not "white".
>>
>> A digital signal can never be white anyway...
>
>In a sampled-time system if each sample is independent from all the rest

>and the mean is zero, then the power spectral density of the
>sampled-time signal will be flat.
>
>Further, if your output is in the form of a train of dirac impulses
>taking on the weighting of the sampled signals then the spectrum in
>continuous time will be flat, also.
>
>I think it's entirely fair to describe such a signal as "white", as long

>as you make sure folks know that it's in sampled time.
>
>--
>
>Tim Wescott
>Wescott Design Services
>http://www.wescottdesign.com
>
>Do you need to implement control loops in software?
>"Applied Control Theory for Embedded Systems" gives you just what it
says.
>See details at http://www.wescottdesign.com/actfes/actfes.html
>I am sorry guys that i was not that clear with my question. So the
spectrum i want for the binary signal is that it should be as flat as
possible until the 2Hz and roll off at 2HZ. I think i cant say it entirely
as white but i want this kind of a binary signal.
Ok step is the clock step , which is if i have a file of input data it
reads each line at every clock step which here is the 0.01ms.
To Julius: The PWM is pulse width modulation. I used a random spike
generator and a sinusoidal signal. Compared both signals to get the binary
signal.
Yes i can take the ascii values of the output and read it into other, but
consider i have a time interval of my output till 1000 (generated matlab
output so units here doesnt matter).If i read this into an another
software(which is a neural software, where the time is taken in ms) it
reads the entire input data to only 10 ms since my time step there is
0.01ms. So you see here my input gets compressed when it is read but i
want my software to read it as 1000ms itself and i dont want to change my
time step there as it will effect the accuracy of output of my software.

I hope i am clear with the question this time.
Thanks
Pavan
```
```pa1kumar wrote:
> Hi,
>
> I am trying to generate a random binary white noise signal such that when
> we take the auto spectrum of the signal it should roll of at 2Hz. I tried
> to do that by PWM but wasn't close. I was wondering if there is any better
> way to do this?
>
> I want to use this signal as an input in other software where the time is
> taken as a default milliseconds(ms) and the time step is 0.01ms. Is there
> a way to make my output in matlab compatible with the other software.
>
> Any help regarding this would be great.
>
> Thanks
> Pavan
>
>
By "binary" I assume that you mean a sampled-time signal that can take
on values of only -1 and 1, or perhaps 0 and 1.

If this is so, your problem is to generate a train of 0's and 1's,
evenly sampled, whose spectrum is flat (more or less) out to 2kHz and
rolls off from there.

Do I have that right?

Do you want the roll-off to be internal, i.e. do you just care about the
spectrum of the binary signal, or do you want to convert this to
continuous-time, and do you then care about the spectrum of the
real-world signal?  Do you want to take the sinc(f) shaping of the
output (I assume you're thinking of using a zero-order hold for the
output) into account?  Do you want to take aliasing into account?

This is a problem that could occupy one for some time -- you're mixing a
nonlinear process (something that _must_ have a binary output) with a
means of analysis (spectral) that is centered on linear systems.  You're
not going to get away from having to deal with the nonlinear system part
of this, no matter how you try.

I think I would start by investigating a sigma-delta converter sort of
topology, with a loop that contains an integrator and a 1-bit modulator.
I'd feed the thing with "white" binary data (by my definition, Randy),
and I'd see if I could find a gain for the integrator that would give me
joy.  I'd start by playing with it in simulation just to see if it looks
possible.  Then if I _really_ had to know what the spectral
characteristics of the output were, I'd try to come up with a
closed-form solution for the autocorrelation function and get a spectrum
(either closed-form or numerical) from that.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```Randy Yates wrote:
> julius <juliusk@gmail.com> writes:
>> [...]
>> Strictly speaking, it is not "white".
>
> A digital signal can never be white anyway...

In a sampled-time system if each sample is independent from all the rest
and the mean is zero, then the power spectral density of the
sampled-time signal will be flat.

Further, if your output is in the form of a train of dirac impulses
taking on the weighting of the sampled signals then the spectrum in
continuous time will be flat, also.

I think it's entirely fair to describe such a signal as "white", as long
as you make sure folks know that it's in sampled time.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" gives you just what it says.
See details at http://www.wescottdesign.com/actfes/actfes.html
```
```Vladimir Vassilevsky <antispam_bogus@hotmail.com> writes:

> Randy Yates wrote:
>
>>>>A digital signal can never be white anyway...
>>>
>>>If you're going to be picky then no signal can ever be white, since it
>>>would require infinite power.
>> It can on paper. A digital signal can never be white, even on paper.
>
> You mean the cyclostationarity?

Yes.

> BTW, the sampling does not have to be
> regular. It can be random as well.

Hmm - that hurts the gray matter.
--
%  Randy Yates                  % "Ticket to the moon, flight leaves here today
%% Fuquay-Varina, NC            %  from Satellite 2"
%%% 919-577-9882                % 'Ticket To The Moon'
%%%% <yates@ieee.org>           % *Time*, Electric Light Orchestra