Testing Parseval's Theorem with Power Spectral Density










0














Suppose I am finding the power spectral density of data like such:



x = winter_data.values #measured at frequency 1Hz
f, Sxx = sp.signal.welch(x1, fs=1, window='hanning', nperseg=N, noverlap = N / 2)


I want to test that Parseval's theorem works on these data sets. Since welch returns the power spectral density, should we not have



np.trapz(x**2, dx=1)


and



len(x1)*np.trapz(Sxx, f)


equal to eachother? Or is my definition of power spectral density incorrect? (np.trapz() is just used to calculate the integrals). I always thought that power spectral density was defined as



S_xx(f) = (1/T)|X(f)|^2



Currently I am not getting them equal.










share|improve this question





















  • They are approxmatively equal for some test data I made up. The windowing procedure will make them non equal anyway. What error do you have?
    – Pierre de Buyl
    Nov 13 '18 at 12:11










  • I'm getting 100000 for the np.trapz(x**2, dx=1) and 1000000 for len(x1)*np.trapz(Sxx, f). So abour 10x greater.
    – Luke Polson
    Nov 14 '18 at 4:17










  • It is possible that the DC componennt is removed by welch. Could you try np.trapz((x-x.mean())**2, dx=1)?
    – Pierre de Buyl
    Nov 14 '18 at 8:28















0














Suppose I am finding the power spectral density of data like such:



x = winter_data.values #measured at frequency 1Hz
f, Sxx = sp.signal.welch(x1, fs=1, window='hanning', nperseg=N, noverlap = N / 2)


I want to test that Parseval's theorem works on these data sets. Since welch returns the power spectral density, should we not have



np.trapz(x**2, dx=1)


and



len(x1)*np.trapz(Sxx, f)


equal to eachother? Or is my definition of power spectral density incorrect? (np.trapz() is just used to calculate the integrals). I always thought that power spectral density was defined as



S_xx(f) = (1/T)|X(f)|^2



Currently I am not getting them equal.










share|improve this question





















  • They are approxmatively equal for some test data I made up. The windowing procedure will make them non equal anyway. What error do you have?
    – Pierre de Buyl
    Nov 13 '18 at 12:11










  • I'm getting 100000 for the np.trapz(x**2, dx=1) and 1000000 for len(x1)*np.trapz(Sxx, f). So abour 10x greater.
    – Luke Polson
    Nov 14 '18 at 4:17










  • It is possible that the DC componennt is removed by welch. Could you try np.trapz((x-x.mean())**2, dx=1)?
    – Pierre de Buyl
    Nov 14 '18 at 8:28













0












0








0







Suppose I am finding the power spectral density of data like such:



x = winter_data.values #measured at frequency 1Hz
f, Sxx = sp.signal.welch(x1, fs=1, window='hanning', nperseg=N, noverlap = N / 2)


I want to test that Parseval's theorem works on these data sets. Since welch returns the power spectral density, should we not have



np.trapz(x**2, dx=1)


and



len(x1)*np.trapz(Sxx, f)


equal to eachother? Or is my definition of power spectral density incorrect? (np.trapz() is just used to calculate the integrals). I always thought that power spectral density was defined as



S_xx(f) = (1/T)|X(f)|^2



Currently I am not getting them equal.










share|improve this question













Suppose I am finding the power spectral density of data like such:



x = winter_data.values #measured at frequency 1Hz
f, Sxx = sp.signal.welch(x1, fs=1, window='hanning', nperseg=N, noverlap = N / 2)


I want to test that Parseval's theorem works on these data sets. Since welch returns the power spectral density, should we not have



np.trapz(x**2, dx=1)


and



len(x1)*np.trapz(Sxx, f)


equal to eachother? Or is my definition of power spectral density incorrect? (np.trapz() is just used to calculate the integrals). I always thought that power spectral density was defined as



S_xx(f) = (1/T)|X(f)|^2



Currently I am not getting them equal.







scipy signals signal-processing fft






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 12 '18 at 5:53









Luke PolsonLuke Polson

898




898











  • They are approxmatively equal for some test data I made up. The windowing procedure will make them non equal anyway. What error do you have?
    – Pierre de Buyl
    Nov 13 '18 at 12:11










  • I'm getting 100000 for the np.trapz(x**2, dx=1) and 1000000 for len(x1)*np.trapz(Sxx, f). So abour 10x greater.
    – Luke Polson
    Nov 14 '18 at 4:17










  • It is possible that the DC componennt is removed by welch. Could you try np.trapz((x-x.mean())**2, dx=1)?
    – Pierre de Buyl
    Nov 14 '18 at 8:28
















  • They are approxmatively equal for some test data I made up. The windowing procedure will make them non equal anyway. What error do you have?
    – Pierre de Buyl
    Nov 13 '18 at 12:11










  • I'm getting 100000 for the np.trapz(x**2, dx=1) and 1000000 for len(x1)*np.trapz(Sxx, f). So abour 10x greater.
    – Luke Polson
    Nov 14 '18 at 4:17










  • It is possible that the DC componennt is removed by welch. Could you try np.trapz((x-x.mean())**2, dx=1)?
    – Pierre de Buyl
    Nov 14 '18 at 8:28















They are approxmatively equal for some test data I made up. The windowing procedure will make them non equal anyway. What error do you have?
– Pierre de Buyl
Nov 13 '18 at 12:11




They are approxmatively equal for some test data I made up. The windowing procedure will make them non equal anyway. What error do you have?
– Pierre de Buyl
Nov 13 '18 at 12:11












I'm getting 100000 for the np.trapz(x**2, dx=1) and 1000000 for len(x1)*np.trapz(Sxx, f). So abour 10x greater.
– Luke Polson
Nov 14 '18 at 4:17




I'm getting 100000 for the np.trapz(x**2, dx=1) and 1000000 for len(x1)*np.trapz(Sxx, f). So abour 10x greater.
– Luke Polson
Nov 14 '18 at 4:17












It is possible that the DC componennt is removed by welch. Could you try np.trapz((x-x.mean())**2, dx=1)?
– Pierre de Buyl
Nov 14 '18 at 8:28




It is possible that the DC componennt is removed by welch. Could you try np.trapz((x-x.mean())**2, dx=1)?
– Pierre de Buyl
Nov 14 '18 at 8:28












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256536%2ftesting-parsevals-theorem-with-power-spectral-density%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53256536%2ftesting-parsevals-theorem-with-power-spectral-density%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Darth Vader #20

How to how show current date and time by default on contact form 7 in WordPress without taking input from user in datetimepicker

Ondo