<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236071</link>
    <title>MATLAB Central Newsreader - Generate a time series from a PSD</title>
    <description>Feed for thread: Generate a time series from a PSD</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 16 Sep 2008 10:03:02 -0400</pubDate>
      <title>Generate a time series from a PSD</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236071#600531</link>
      <author>Rainer </author>
      <description>Hi,&lt;br&gt;
&lt;br&gt;
I tried to generate a time series (one realization) from a Power Spectral Density (PSD). Since the PSD only contains amplitude information but no phase information, I defined the phase (at each frequency) as a random variable, uniformly distributed between 0 and 2*pi. Basically the code is:&lt;br&gt;
&lt;br&gt;
============================================================&lt;br&gt;
function [x, t] = psd2timeseries(PSD, fNyq)&lt;br&gt;
% x = time series&lt;br&gt;
% t = time vector&lt;br&gt;
% PSD = power spectral density (one-sided, from 0 to fNyq)&lt;br&gt;
% fNyq = nyquist frequency&lt;br&gt;
&lt;br&gt;
N = length(PSD);&lt;br&gt;
&lt;br&gt;
% Compute amplitude of frequency spectrum&lt;br&gt;
SpectrumAmplitude = sqrt(PSD);&lt;br&gt;
&lt;br&gt;
% Compute phase of frequency spectrum&lt;br&gt;
SpectrumPhase = rand(size(PSD))*2.*pi;&lt;br&gt;
&lt;br&gt;
% Compute complex spectrum&lt;br&gt;
Spectrum = SpectrumAmplitude .* exp(i*SpectrumPhase);&lt;br&gt;
&lt;br&gt;
% This is a one-sided PSD, for frequencies between 0 and&lt;br&gt;
% the Nyquist frequency fNyq. We construct a two sided-PSD:&lt;br&gt;
&lt;br&gt;
% Sampling of frequency vector&lt;br&gt;
delta_f = fNyq/(N-1);&lt;br&gt;
&lt;br&gt;
% Generate two-sided frequency vector (as it would result&lt;br&gt;
% from Matlab's fft command for an even number of samples):&lt;br&gt;
f_TwoSided = ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[0 : delta_f : fNyq] ...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[-fNyq + delta_f : delta_f : -delta_f]...&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;];&lt;br&gt;
% ... and generate the two-sided PSD:&lt;br&gt;
Spectrum_TwoSided = [Spectrum(1:1:end) Spectrum(end-1:-1:2)]; &lt;br&gt;
&lt;br&gt;
% Compute inverse FFT&lt;br&gt;
x= ifft(Spectrum);&lt;br&gt;
x= fftshift(x);&lt;br&gt;
x= real(x);&lt;br&gt;
&lt;br&gt;
% Compute time vector&lt;br&gt;
delta_t = 1./(2.*fNyq);&lt;br&gt;
t= [0:delta:(N-1)*delta];&lt;br&gt;
===========================================================&lt;br&gt;
&lt;br&gt;
What I am not sure about is:&lt;br&gt;
* if it is required to build a two-sided PSD prior to computing the inverse FFT with ifft.&lt;br&gt;
* In which ordering the time vector of the resulting time series x (from ifft) will be computed. Is fftshift required?&lt;br&gt;
* The problematic code seems to be:&lt;br&gt;
&lt;br&gt;
x= ifft(Spectrum);&lt;br&gt;
x= fftshift(x);&lt;br&gt;
x= real(x);&lt;br&gt;
&lt;br&gt;
In any case the function does not produce the results I expected. When I am trying, once x and t have been computed, to compute a periodogram using&lt;br&gt;
&lt;br&gt;
[Pxx,freq] = periodogram(x,hanning(length(x)),length(x),2*fNyq);&lt;br&gt;
&lt;br&gt;
the resulting periodogram should resemble to PSD but it does not (at all!).&lt;br&gt;
&lt;br&gt;
Any ideas what went wrong?&lt;br&gt;
&lt;br&gt;
Thanks&lt;br&gt;
Rainer</description>
    </item>
    <item>
      <pubDate>Tue, 16 Sep 2008 11:22:02 -0400</pubDate>
      <title>Re: Generate a time series from a PSD</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236071#600535</link>
      <author>David </author>
      <description>&quot;Rainer &quot; &amp;lt;wilhelm.remove.this.rainer@gmx.net&amp;gt; wrote in message &amp;lt;gao08m$ad3$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I tried to generate a time series (one realization) from a Power Spectral Density (PSD). Since the PSD only contains amplitude information but no phase information, I defined the phase (at each frequency) as a random variable, uniformly distributed between 0 and 2*pi. Basically the code is:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; ============================================================&lt;br&gt;
&amp;gt; function [x, t] = psd2timeseries(PSD, fNyq)&lt;br&gt;
&amp;gt; % x = time series&lt;br&gt;
&amp;gt; % t = time vector&lt;br&gt;
&amp;gt; % PSD = power spectral density (one-sided, from 0 to fNyq)&lt;br&gt;
&amp;gt; % fNyq = nyquist frequency&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; N = length(PSD);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Compute amplitude of frequency spectrum&lt;br&gt;
&amp;gt; SpectrumAmplitude = sqrt(PSD);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Compute phase of frequency spectrum&lt;br&gt;
&amp;gt; SpectrumPhase = rand(size(PSD))*2.*pi;&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Compute complex spectrum&lt;br&gt;
&amp;gt; Spectrum = SpectrumAmplitude .* exp(i*SpectrumPhase);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % This is a one-sided PSD, for frequencies between 0 and&lt;br&gt;
&amp;gt; % the Nyquist frequency fNyq. We construct a two sided-PSD:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Sampling of frequency vector&lt;br&gt;
&amp;gt; delta_f = fNyq/(N-1);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Generate two-sided frequency vector (as it would result&lt;br&gt;
&amp;gt; % from Matlab's fft command for an even number of samples):&lt;br&gt;
&amp;gt; f_TwoSided = ...&lt;br&gt;
&amp;gt;     [...&lt;br&gt;
&amp;gt;     [0 : delta_f : fNyq] ...&lt;br&gt;
&amp;gt;     [-fNyq + delta_f : delta_f : -delta_f]...&lt;br&gt;
&amp;gt;     ];&lt;br&gt;
&amp;gt; % ... and generate the two-sided PSD:&lt;br&gt;
&amp;gt; Spectrum_TwoSided = [Spectrum(1:1:end) Spectrum(end-1:-1:2)]; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Compute inverse FFT&lt;br&gt;
&amp;gt; x= ifft(Spectrum);&lt;br&gt;
&amp;gt; x= fftshift(x);&lt;br&gt;
&amp;gt; x= real(x);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; % Compute time vector&lt;br&gt;
&amp;gt; delta_t = 1./(2.*fNyq);&lt;br&gt;
&amp;gt; t= [0:delta:(N-1)*delta];&lt;br&gt;
&amp;gt; ===========================================================&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; What I am not sure about is:&lt;br&gt;
&amp;gt; * if it is required to build a two-sided PSD prior to computing the inverse FFT with ifft.&lt;br&gt;
&amp;gt; * In which ordering the time vector of the resulting time series x (from ifft) will be computed. Is fftshift required?&lt;br&gt;
&amp;gt; * The problematic code seems to be:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; x= ifft(Spectrum);&lt;br&gt;
&amp;gt; x= fftshift(x);&lt;br&gt;
&amp;gt; x= real(x);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; In any case the function does not produce the results I expected. When I am trying, once x and t have been computed, to compute a periodogram using&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; [Pxx,freq] = periodogram(x,hanning(length(x)),length(x),2*fNyq);&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; the resulting periodogram should resemble to PSD but it does not (at all!).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Any ideas what went wrong?&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; Rainer&lt;br&gt;
&lt;br&gt;
why bother with a random phase?  it would seem to add complexity while you are trying to figure out the basics.  I would leave it as zero until you get the basic ifft working then consider whether you really have to muck with it at all.&lt;br&gt;
&lt;br&gt;
also, why are you doing the fftshift after the ifft?  fftshift takes the results of doing an fft and swaps the vector halves so the zero frequency is in the middle... doing the fftshift after an ifft swaps the left and right halves of the time sequence which wouldn't seem to make sense.  you might need to do ifftshift before the ifft if your psd that you have duplicated has the zero frequency in the middle of the vector.</description>
    </item>
    <item>
      <pubDate>Tue, 16 Sep 2008 20:07:23 -0400</pubDate>
      <title>Re: Generate a time series from a PSD</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236071#600611</link>
      <author>NZTideMan</author>
      <description>On Sep 16, 10:03=A0pm, &quot;Rainer &quot; &amp;lt;wilhelm.remove.this.rai...@gmx.net&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I tried to generate a time series (one realization) from a Power Spectral=&lt;br&gt;
&amp;nbsp;Density (PSD). Since the PSD only contains amplitude information but no ph=&lt;br&gt;
ase information, I defined the phase (at each frequency) as a random variab=&lt;br&gt;
le, uniformly distributed between 0 and 2*pi. Basically the code is:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=&lt;br&gt;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=&lt;br&gt;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D&lt;br&gt;
&amp;gt; function [x, t] =3D psd2timeseries(PSD, fNyq)&lt;br&gt;
&amp;gt; % x =3D time series&lt;br&gt;
&amp;gt; % t =3D time vector&lt;br&gt;
&amp;gt; % PSD =3D power spectral density (one-sided, from 0 to fNyq)&lt;br&gt;
&amp;gt; % fNyq =3D nyquist frequency&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; N =3D length(PSD);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute amplitude of frequency spectrum&lt;br&gt;
&amp;gt; SpectrumAmplitude =3D sqrt(PSD);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute phase of frequency spectrum&lt;br&gt;
&amp;gt; SpectrumPhase =3D rand(size(PSD))*2.*pi;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute complex spectrum&lt;br&gt;
&amp;gt; Spectrum =3D SpectrumAmplitude .* exp(i*SpectrumPhase);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % This is a one-sided PSD, for frequencies between 0 and&lt;br&gt;
&amp;gt; % the Nyquist frequency fNyq. We construct a two sided-PSD:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Sampling of frequency vector&lt;br&gt;
&amp;gt; delta_f =3D fNyq/(N-1);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Generate two-sided frequency vector (as it would result&lt;br&gt;
&amp;gt; % from Matlab's fft command for an even number of samples):&lt;br&gt;
&amp;gt; f_TwoSided =3D ...&lt;br&gt;
&amp;gt; =A0 =A0 [...&lt;br&gt;
&amp;gt; =A0 =A0 [0 : delta_f : fNyq] ...&lt;br&gt;
&amp;gt; =A0 =A0 [-fNyq + delta_f : delta_f : -delta_f]...&lt;br&gt;
&amp;gt; =A0 =A0 ];&lt;br&gt;
&amp;gt; % ... and generate the two-sided PSD:&lt;br&gt;
&amp;gt; Spectrum_TwoSided =3D [Spectrum(1:1:end) Spectrum(end-1:-1:2)];&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute inverse FFT&lt;br&gt;
&amp;gt; x=3D ifft(Spectrum);&lt;br&gt;
&amp;gt; x=3D fftshift(x);&lt;br&gt;
&amp;gt; x=3D real(x);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute time vector&lt;br&gt;
&amp;gt; delta_t =3D 1./(2.*fNyq);&lt;br&gt;
&amp;gt; t=3D [0:delta:(N-1)*delta];&lt;br&gt;
&amp;gt; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=&lt;br&gt;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=&lt;br&gt;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; What I am not sure about is:&lt;br&gt;
&amp;gt; * if it is required to build a two-sided PSD prior to computing the inver=&lt;br&gt;
se FFT with ifft.&lt;br&gt;
&amp;gt; * In which ordering the time vector of the resulting time series x (from =&lt;br&gt;
ifft) will be computed. Is fftshift required?&lt;br&gt;
&amp;gt; * The problematic code seems to be:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; x=3D ifft(Spectrum);&lt;br&gt;
&amp;gt; x=3D fftshift(x);&lt;br&gt;
&amp;gt; x=3D real(x);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; In any case the function does not produce the results I expected. When I =&lt;br&gt;
am trying, once x and t have been computed, to compute a periodogram using&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; [Pxx,freq] =3D periodogram(x,hanning(length(x)),length(x),2*fNyq);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; the resulting periodogram should resemble to PSD but it does not (at all!=&lt;br&gt;
).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Any ideas what went wrong?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; Rainer&lt;br&gt;
&lt;br&gt;
Fundamental error:&lt;br&gt;
x=3D ifft(Spectrum);&lt;br&gt;
should be:&lt;br&gt;
x=3D ifft(Spectrum_TwoSided);&lt;br&gt;
You went to all the trouble of making Spectrum_TwoSided, then failed&lt;br&gt;
to use it.&lt;br&gt;
&lt;br&gt;
One thing I noticed with your algorithm is that the phase at zero&lt;br&gt;
frequency in Spectrum is nonzero.  It should be zero.  I'm not sure&lt;br&gt;
what effect this will have.&lt;br&gt;
Also, you need to be careful how you butt the two parts of the&lt;br&gt;
spectrum together:&lt;br&gt;
Spectrum_TwoSided =3D [Spectrum(1:1:end) Spectrum(end-1:-1:2)];&lt;br&gt;
This will yield an odd number of data in x.&lt;br&gt;
You may like to try inserting a zero between them.  This will give an&lt;br&gt;
even number in x.</description>
    </item>
    <item>
      <pubDate>Wed, 24 Sep 2008 13:05:05 -0400</pubDate>
      <title>Re: Generate a time series from a PSD</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236071#601867</link>
      <author>SmartEngineer </author>
      <description>Hello Rainer,&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Is the code working for you with the suggestion mentioned above.Can you please the final working code.I am trying to work on a similar application and it will be great if you dont mind sharing the work you have carried out.&lt;br&gt;
&lt;br&gt;
Thanks and Best Wishes.</description>
    </item>
    <item>
      <pubDate>Sat, 27 Sep 2008 08:16:45 -0400</pubDate>
      <title>Re: Generate a time series from a PSD</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236071#602487</link>
      <author>Greg Heath</author>
      <description>On Sep 16, 6:03=A0am, &quot;Rainer &quot; &amp;lt;wilhelm.remove.this.rai...@gmx.net&amp;gt;&lt;br&gt;
wrote:&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; I tried to generate a time series (one realization) from a Power Spectral=&lt;br&gt;
&amp;nbsp;Density (PSD). Since the PSD only contains amplitude information but no ph=&lt;br&gt;
ase information, I defined the phase (at each frequency) as a random variab=&lt;br&gt;
le, uniformly distributed between 0 and 2*pi.&lt;br&gt;
&lt;br&gt;
Wouldn't it be better to estimate phase using log(PSD) and&lt;br&gt;
a Hilbert transform?&lt;br&gt;
&lt;br&gt;
Hope that helps.&lt;br&gt;
&lt;br&gt;
Greg&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Basically the code is:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=&lt;br&gt;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=&lt;br&gt;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D&lt;br&gt;
&amp;gt; function [x, t] =3D psd2timeseries(PSD, fNyq)&lt;br&gt;
&amp;gt; % x =3D time series&lt;br&gt;
&amp;gt; % t =3D time vector&lt;br&gt;
&amp;gt; % PSD =3D power spectral density (one-sided, from 0 to fNyq)&lt;br&gt;
&amp;gt; % fNyq =3D nyquist frequency&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; N =3D length(PSD);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute amplitude of frequency spectrum&lt;br&gt;
&amp;gt; SpectrumAmplitude =3D sqrt(PSD);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute phase of frequency spectrum&lt;br&gt;
&amp;gt; SpectrumPhase =3D rand(size(PSD))*2.*pi;&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute complex spectrum&lt;br&gt;
&amp;gt; Spectrum =3D SpectrumAmplitude .* exp(i*SpectrumPhase);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % This is a one-sided PSD, for frequencies between 0 and&lt;br&gt;
&amp;gt; % the Nyquist frequency fNyq. We construct a two sided-PSD:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Sampling of frequency vector&lt;br&gt;
&amp;gt; delta_f =3D fNyq/(N-1);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Generate two-sided frequency vector (as it would result&lt;br&gt;
&amp;gt; % from Matlab's fft command for an even number of samples):&lt;br&gt;
&amp;gt; f_TwoSided =3D ...&lt;br&gt;
&amp;gt; =A0 =A0 [...&lt;br&gt;
&amp;gt; =A0 =A0 [0 : delta_f : fNyq] ...&lt;br&gt;
&amp;gt; =A0 =A0 [-fNyq + delta_f : delta_f : -delta_f]...&lt;br&gt;
&amp;gt; =A0 =A0 ];&lt;br&gt;
&amp;gt; % ... and generate the two-sided PSD:&lt;br&gt;
&amp;gt; Spectrum_TwoSided =3D [Spectrum(1:1:end) Spectrum(end-1:-1:2)];&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute inverse FFT&lt;br&gt;
&amp;gt; x=3D ifft(Spectrum);&lt;br&gt;
&amp;gt; x=3D fftshift(x);&lt;br&gt;
&amp;gt; x=3D real(x);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; % Compute time vector&lt;br&gt;
&amp;gt; delta_t =3D 1./(2.*fNyq);&lt;br&gt;
&amp;gt; t=3D [0:delta:(N-1)*delta];&lt;br&gt;
&amp;gt; =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=&lt;br&gt;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=&lt;br&gt;
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; What I am not sure about is:&lt;br&gt;
&amp;gt; * if it is required to build a two-sided PSD prior to computing the inver=&lt;br&gt;
se FFT with ifft.&lt;br&gt;
&amp;gt; * In which ordering the time vector of the resulting time series x (from =&lt;br&gt;
ifft) will be computed. Is fftshift required?&lt;br&gt;
&amp;gt; * The problematic code seems to be:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; x=3D ifft(Spectrum);&lt;br&gt;
&amp;gt; x=3D fftshift(x);&lt;br&gt;
&amp;gt; x=3D real(x);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; In any case the function does not produce the results I expected. When I =&lt;br&gt;
am trying, once x and t have been computed, to compute a periodogram using&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; [Pxx,freq] =3D periodogram(x,hanning(length(x)),length(x),2*fNyq);&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; the resulting periodogram should resemble to PSD but it does not (at all!=&lt;br&gt;
).&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Any ideas what went wrong?&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; Thanks&lt;br&gt;
&amp;gt; Rainer</description>
    </item>
    <item>
      <pubDate>Sat, 27 Sep 2008 13:30:05 -0400</pubDate>
      <title>Re: Generate a time series from a PSD</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/236071#602521</link>
      <author>Matt </author>
      <description>&quot;Rainer &quot; &amp;lt;wilhelm.remove.this.rainer@gmx.net&amp;gt; wrote in message &amp;lt;gao08m$ad3$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I tried to generate a time series (one realization) from a Power Spectral Density (PSD). Since the PSD only contains amplitude information but no phase information, I defined the phase (at each frequency) as a random variable, uniformly distributed between 0 and 2*pi. Basically the code is:&lt;br&gt;
-------------------&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
If the idea is to get a realization of the time series, do you really need phase information? Do you really need to take this approach at all?&lt;br&gt;
&lt;br&gt;
It seems like what you're trying to do is express the time series as the output of some filter when fed with white noise input. You're trying to recreate that filter and are finding that the PSD only gives you its magnitude response.&lt;br&gt;
&lt;br&gt;
But if the goal is just to get a realization of the time series, it seems to me that all you have to do is compute the autocorrelation function by doing an ifft on the PSD.&lt;br&gt;
&lt;br&gt;
Once you have the autocorrelation function, you can reconstruct the joint probability distribution function of the time series, if you assume the time series is Gaussian. &lt;br&gt;
&lt;br&gt;
Once you have the joint distribution, you can compute a realization.</description>
    </item>
  </channel>
</rss>

