Unexpected behaviour of PowerSpectralDensity

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I recently wanted to calculate the power spectral density of a surface profile. I was happy to find out that there is a built in PowerSpectralDensity function in Mathematica (version 10). However, I'm surprised to find the following behaviour:



straightline = Range[1, 10, 0.2];
Plot[PowerSpectralDensity[straightline, w], w, 0.1, 10]


gives:



enter image description here



Note that 2Pi=6.28. Now, from my very faint recollection of University classes, I assumed this should be flat or at least similar to



ListPlot[Abs[Fourier[straightline]]^2]


Why is it not? Why do we get this result?



It probably has to do with the window function w since 2w moves the position of the peak by a factor of 1/2.










share|improve this question



























    up vote
    2
    down vote

    favorite












    I recently wanted to calculate the power spectral density of a surface profile. I was happy to find out that there is a built in PowerSpectralDensity function in Mathematica (version 10). However, I'm surprised to find the following behaviour:



    straightline = Range[1, 10, 0.2];
    Plot[PowerSpectralDensity[straightline, w], w, 0.1, 10]


    gives:



    enter image description here



    Note that 2Pi=6.28. Now, from my very faint recollection of University classes, I assumed this should be flat or at least similar to



    ListPlot[Abs[Fourier[straightline]]^2]


    Why is it not? Why do we get this result?



    It probably has to do with the window function w since 2w moves the position of the peak by a factor of 1/2.










    share|improve this question

























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I recently wanted to calculate the power spectral density of a surface profile. I was happy to find out that there is a built in PowerSpectralDensity function in Mathematica (version 10). However, I'm surprised to find the following behaviour:



      straightline = Range[1, 10, 0.2];
      Plot[PowerSpectralDensity[straightline, w], w, 0.1, 10]


      gives:



      enter image description here



      Note that 2Pi=6.28. Now, from my very faint recollection of University classes, I assumed this should be flat or at least similar to



      ListPlot[Abs[Fourier[straightline]]^2]


      Why is it not? Why do we get this result?



      It probably has to do with the window function w since 2w moves the position of the peak by a factor of 1/2.










      share|improve this question















      I recently wanted to calculate the power spectral density of a surface profile. I was happy to find out that there is a built in PowerSpectralDensity function in Mathematica (version 10). However, I'm surprised to find the following behaviour:



      straightline = Range[1, 10, 0.2];
      Plot[PowerSpectralDensity[straightline, w], w, 0.1, 10]


      gives:



      enter image description here



      Note that 2Pi=6.28. Now, from my very faint recollection of University classes, I assumed this should be flat or at least similar to



      ListPlot[Abs[Fourier[straightline]]^2]


      Why is it not? Why do we get this result?



      It probably has to do with the window function w since 2w moves the position of the peak by a factor of 1/2.







      fourier-analysis






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 1 hour ago









      Glorfindel

      1591211




      1591211










      asked 3 hours ago









      Kab

      1007




      1007




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          They are the same, sort of. You can make PowerSpectralDensity and Fourier show the same plot:



          straightline = Range[1, 10, 0.2];
          straightline = straightline - Mean[straightline];
          ListPlot[Table[PowerSpectralDensity[straightline, w],
          w, 0, 2 Pi-0.001, 2 Pi/Length[straightline]], PlotRange -> All]

          ListPlot[Abs[Fourier[straightline]]^2, PlotRange -> All]


          enter image description here



          The main difference is that the PowerSpectralDensity (PSD) is reported as a (continuous-valued) function of frequency, while Fourier just calculates samples of this function. So to make the plots the same, we need to sample the PSD at the same points. A minor difference is that the PSD more or less assumes a zero mean signal, so to make them match, the code above removes the DC/constant term. Outside of 0,2 Pi, both functions repeat with period 2 Pi, which in this case, is the complete list of 40-some points.






          share|improve this answer






















          • thanks bill. Why did you exclude the 2Pi datapoint?
            – Kab
            1 hour ago










          • The zero point and the 2 Pi point are the same, due to the periodicity, so it seemed cleaner to remove it.
            – bill s
            1 hour ago











          Your Answer




          StackExchange.ifUsing("editor", function ()
          return StackExchange.using("mathjaxEditing", function ()
          StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
          StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
          );
          );
          , "mathjax-editing");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "387"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184024%2funexpected-behaviour-of-powerspectraldensity%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          4
          down vote



          accepted










          They are the same, sort of. You can make PowerSpectralDensity and Fourier show the same plot:



          straightline = Range[1, 10, 0.2];
          straightline = straightline - Mean[straightline];
          ListPlot[Table[PowerSpectralDensity[straightline, w],
          w, 0, 2 Pi-0.001, 2 Pi/Length[straightline]], PlotRange -> All]

          ListPlot[Abs[Fourier[straightline]]^2, PlotRange -> All]


          enter image description here



          The main difference is that the PowerSpectralDensity (PSD) is reported as a (continuous-valued) function of frequency, while Fourier just calculates samples of this function. So to make the plots the same, we need to sample the PSD at the same points. A minor difference is that the PSD more or less assumes a zero mean signal, so to make them match, the code above removes the DC/constant term. Outside of 0,2 Pi, both functions repeat with period 2 Pi, which in this case, is the complete list of 40-some points.






          share|improve this answer






















          • thanks bill. Why did you exclude the 2Pi datapoint?
            – Kab
            1 hour ago










          • The zero point and the 2 Pi point are the same, due to the periodicity, so it seemed cleaner to remove it.
            – bill s
            1 hour ago















          up vote
          4
          down vote



          accepted










          They are the same, sort of. You can make PowerSpectralDensity and Fourier show the same plot:



          straightline = Range[1, 10, 0.2];
          straightline = straightline - Mean[straightline];
          ListPlot[Table[PowerSpectralDensity[straightline, w],
          w, 0, 2 Pi-0.001, 2 Pi/Length[straightline]], PlotRange -> All]

          ListPlot[Abs[Fourier[straightline]]^2, PlotRange -> All]


          enter image description here



          The main difference is that the PowerSpectralDensity (PSD) is reported as a (continuous-valued) function of frequency, while Fourier just calculates samples of this function. So to make the plots the same, we need to sample the PSD at the same points. A minor difference is that the PSD more or less assumes a zero mean signal, so to make them match, the code above removes the DC/constant term. Outside of 0,2 Pi, both functions repeat with period 2 Pi, which in this case, is the complete list of 40-some points.






          share|improve this answer






















          • thanks bill. Why did you exclude the 2Pi datapoint?
            – Kab
            1 hour ago










          • The zero point and the 2 Pi point are the same, due to the periodicity, so it seemed cleaner to remove it.
            – bill s
            1 hour ago













          up vote
          4
          down vote



          accepted







          up vote
          4
          down vote



          accepted






          They are the same, sort of. You can make PowerSpectralDensity and Fourier show the same plot:



          straightline = Range[1, 10, 0.2];
          straightline = straightline - Mean[straightline];
          ListPlot[Table[PowerSpectralDensity[straightline, w],
          w, 0, 2 Pi-0.001, 2 Pi/Length[straightline]], PlotRange -> All]

          ListPlot[Abs[Fourier[straightline]]^2, PlotRange -> All]


          enter image description here



          The main difference is that the PowerSpectralDensity (PSD) is reported as a (continuous-valued) function of frequency, while Fourier just calculates samples of this function. So to make the plots the same, we need to sample the PSD at the same points. A minor difference is that the PSD more or less assumes a zero mean signal, so to make them match, the code above removes the DC/constant term. Outside of 0,2 Pi, both functions repeat with period 2 Pi, which in this case, is the complete list of 40-some points.






          share|improve this answer














          They are the same, sort of. You can make PowerSpectralDensity and Fourier show the same plot:



          straightline = Range[1, 10, 0.2];
          straightline = straightline - Mean[straightline];
          ListPlot[Table[PowerSpectralDensity[straightline, w],
          w, 0, 2 Pi-0.001, 2 Pi/Length[straightline]], PlotRange -> All]

          ListPlot[Abs[Fourier[straightline]]^2, PlotRange -> All]


          enter image description here



          The main difference is that the PowerSpectralDensity (PSD) is reported as a (continuous-valued) function of frequency, while Fourier just calculates samples of this function. So to make the plots the same, we need to sample the PSD at the same points. A minor difference is that the PSD more or less assumes a zero mean signal, so to make them match, the code above removes the DC/constant term. Outside of 0,2 Pi, both functions repeat with period 2 Pi, which in this case, is the complete list of 40-some points.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 2 hours ago

























          answered 2 hours ago









          bill s

          51.5k375146




          51.5k375146











          • thanks bill. Why did you exclude the 2Pi datapoint?
            – Kab
            1 hour ago










          • The zero point and the 2 Pi point are the same, due to the periodicity, so it seemed cleaner to remove it.
            – bill s
            1 hour ago

















          • thanks bill. Why did you exclude the 2Pi datapoint?
            – Kab
            1 hour ago










          • The zero point and the 2 Pi point are the same, due to the periodicity, so it seemed cleaner to remove it.
            – bill s
            1 hour ago
















          thanks bill. Why did you exclude the 2Pi datapoint?
          – Kab
          1 hour ago




          thanks bill. Why did you exclude the 2Pi datapoint?
          – Kab
          1 hour ago












          The zero point and the 2 Pi point are the same, due to the periodicity, so it seemed cleaner to remove it.
          – bill s
          1 hour ago





          The zero point and the 2 Pi point are the same, due to the periodicity, so it seemed cleaner to remove it.
          – bill s
          1 hour ago


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184024%2funexpected-behaviour-of-powerspectraldensity%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Displaying single band from multi-band raster using QGIS

          How many registers does an x86_64 CPU actually have?