How to plot the normal distribution?












0












$begingroup$


According to 'An Introduction to Probability Theory and Its Applications', Vol. 1 by Feller the number of inversions in a random permutations at large numbers satisfy CLT with dedicated mean and variance.



However, I am practically intrested in how to plot the figure of the normal distribution (what to calculate for it)?



I understand that the figure may depends on the fact of how large the numbers are. Any explanations to clarify the topic are highly welcomed. Thank you in advance.










share|cite|improve this question









$endgroup$












  • $begingroup$
    Do you want to plot the PDF $frac{1}{sigmasqrt{2pi}}exp-frac{(x-mu)^2}{2sigma^2}$ or the CDF $frac{1}{2}left[1+operatorname{erf}left(frac{x-mu}{sigmasqrt{2}}right)right]$? Either way, the case $mu=0,,sigma=1$ is worth using for definiteness.
    $endgroup$
    – J.G.
    Dec 20 '18 at 19:52










  • $begingroup$
    The PDF one, which depends on the number of elements
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:06
















0












$begingroup$


According to 'An Introduction to Probability Theory and Its Applications', Vol. 1 by Feller the number of inversions in a random permutations at large numbers satisfy CLT with dedicated mean and variance.



However, I am practically intrested in how to plot the figure of the normal distribution (what to calculate for it)?



I understand that the figure may depends on the fact of how large the numbers are. Any explanations to clarify the topic are highly welcomed. Thank you in advance.










share|cite|improve this question









$endgroup$












  • $begingroup$
    Do you want to plot the PDF $frac{1}{sigmasqrt{2pi}}exp-frac{(x-mu)^2}{2sigma^2}$ or the CDF $frac{1}{2}left[1+operatorname{erf}left(frac{x-mu}{sigmasqrt{2}}right)right]$? Either way, the case $mu=0,,sigma=1$ is worth using for definiteness.
    $endgroup$
    – J.G.
    Dec 20 '18 at 19:52










  • $begingroup$
    The PDF one, which depends on the number of elements
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:06














0












0








0





$begingroup$


According to 'An Introduction to Probability Theory and Its Applications', Vol. 1 by Feller the number of inversions in a random permutations at large numbers satisfy CLT with dedicated mean and variance.



However, I am practically intrested in how to plot the figure of the normal distribution (what to calculate for it)?



I understand that the figure may depends on the fact of how large the numbers are. Any explanations to clarify the topic are highly welcomed. Thank you in advance.










share|cite|improve this question









$endgroup$




According to 'An Introduction to Probability Theory and Its Applications', Vol. 1 by Feller the number of inversions in a random permutations at large numbers satisfy CLT with dedicated mean and variance.



However, I am practically intrested in how to plot the figure of the normal distribution (what to calculate for it)?



I understand that the figure may depends on the fact of how large the numbers are. Any explanations to clarify the topic are highly welcomed. Thank you in advance.







probability-theory probability-distributions






share|cite|improve this question













share|cite|improve this question











share|cite|improve this question




share|cite|improve this question










asked Dec 20 '18 at 19:43









Mikhail GaichenkovMikhail Gaichenkov

6610




6610












  • $begingroup$
    Do you want to plot the PDF $frac{1}{sigmasqrt{2pi}}exp-frac{(x-mu)^2}{2sigma^2}$ or the CDF $frac{1}{2}left[1+operatorname{erf}left(frac{x-mu}{sigmasqrt{2}}right)right]$? Either way, the case $mu=0,,sigma=1$ is worth using for definiteness.
    $endgroup$
    – J.G.
    Dec 20 '18 at 19:52










  • $begingroup$
    The PDF one, which depends on the number of elements
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:06


















  • $begingroup$
    Do you want to plot the PDF $frac{1}{sigmasqrt{2pi}}exp-frac{(x-mu)^2}{2sigma^2}$ or the CDF $frac{1}{2}left[1+operatorname{erf}left(frac{x-mu}{sigmasqrt{2}}right)right]$? Either way, the case $mu=0,,sigma=1$ is worth using for definiteness.
    $endgroup$
    – J.G.
    Dec 20 '18 at 19:52










  • $begingroup$
    The PDF one, which depends on the number of elements
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:06
















$begingroup$
Do you want to plot the PDF $frac{1}{sigmasqrt{2pi}}exp-frac{(x-mu)^2}{2sigma^2}$ or the CDF $frac{1}{2}left[1+operatorname{erf}left(frac{x-mu}{sigmasqrt{2}}right)right]$? Either way, the case $mu=0,,sigma=1$ is worth using for definiteness.
$endgroup$
– J.G.
Dec 20 '18 at 19:52




$begingroup$
Do you want to plot the PDF $frac{1}{sigmasqrt{2pi}}exp-frac{(x-mu)^2}{2sigma^2}$ or the CDF $frac{1}{2}left[1+operatorname{erf}left(frac{x-mu}{sigmasqrt{2}}right)right]$? Either way, the case $mu=0,,sigma=1$ is worth using for definiteness.
$endgroup$
– J.G.
Dec 20 '18 at 19:52












$begingroup$
The PDF one, which depends on the number of elements
$endgroup$
– Mikhail Gaichenkov
Dec 20 '18 at 20:06




$begingroup$
The PDF one, which depends on the number of elements
$endgroup$
– Mikhail Gaichenkov
Dec 20 '18 at 20:06










1 Answer
1






active

oldest

votes


















1












$begingroup$

Here is how to plot the density function of $N(0,1)$:
$$
f(x) = frac{e^{-frac{x^2}{2}}}{sqrt{2 pi}} .
$$



In Mathematica, a one-liner:



Plot[PDF[NormalDistribution, x], {x, -4, 4}]


enter image description here



In Python, slightly more verbose:



import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-4, 4, 101)
y = np.exp(-x*x/2) / np.sqrt(2*np.pi)

plt.plot(x, y)
plt.show()


enter image description here






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Thank you, Federico! How can I get the N(0,1) if there are mean and variance which depend on the number of elements?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 19:56










  • $begingroup$
    Translate and rescale: if $Zsim N(mu,sigma)$, then $(Z-mu)/sigmasim N(0,1)$.
    $endgroup$
    – Federico
    Dec 20 '18 at 19:58










  • $begingroup$
    Could you add the figures here for mean=n(n-1)/4, variance=(2n^3+3n^2-5n)/72 at n=10, 100, 1000?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:04










  • $begingroup$
    They don't look any different from the one I plotted. They are just translated and stretched. Only the numbers on the axes change
    $endgroup$
    – Federico
    Dec 20 '18 at 20:08












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: "69"
};
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
},
noCode: true, onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmath.stackexchange.com%2fquestions%2f3047905%2fhow-to-plot-the-normal-distribution%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1












$begingroup$

Here is how to plot the density function of $N(0,1)$:
$$
f(x) = frac{e^{-frac{x^2}{2}}}{sqrt{2 pi}} .
$$



In Mathematica, a one-liner:



Plot[PDF[NormalDistribution, x], {x, -4, 4}]


enter image description here



In Python, slightly more verbose:



import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-4, 4, 101)
y = np.exp(-x*x/2) / np.sqrt(2*np.pi)

plt.plot(x, y)
plt.show()


enter image description here






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Thank you, Federico! How can I get the N(0,1) if there are mean and variance which depend on the number of elements?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 19:56










  • $begingroup$
    Translate and rescale: if $Zsim N(mu,sigma)$, then $(Z-mu)/sigmasim N(0,1)$.
    $endgroup$
    – Federico
    Dec 20 '18 at 19:58










  • $begingroup$
    Could you add the figures here for mean=n(n-1)/4, variance=(2n^3+3n^2-5n)/72 at n=10, 100, 1000?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:04










  • $begingroup$
    They don't look any different from the one I plotted. They are just translated and stretched. Only the numbers on the axes change
    $endgroup$
    – Federico
    Dec 20 '18 at 20:08
















1












$begingroup$

Here is how to plot the density function of $N(0,1)$:
$$
f(x) = frac{e^{-frac{x^2}{2}}}{sqrt{2 pi}} .
$$



In Mathematica, a one-liner:



Plot[PDF[NormalDistribution, x], {x, -4, 4}]


enter image description here



In Python, slightly more verbose:



import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-4, 4, 101)
y = np.exp(-x*x/2) / np.sqrt(2*np.pi)

plt.plot(x, y)
plt.show()


enter image description here






share|cite|improve this answer









$endgroup$













  • $begingroup$
    Thank you, Federico! How can I get the N(0,1) if there are mean and variance which depend on the number of elements?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 19:56










  • $begingroup$
    Translate and rescale: if $Zsim N(mu,sigma)$, then $(Z-mu)/sigmasim N(0,1)$.
    $endgroup$
    – Federico
    Dec 20 '18 at 19:58










  • $begingroup$
    Could you add the figures here for mean=n(n-1)/4, variance=(2n^3+3n^2-5n)/72 at n=10, 100, 1000?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:04










  • $begingroup$
    They don't look any different from the one I plotted. They are just translated and stretched. Only the numbers on the axes change
    $endgroup$
    – Federico
    Dec 20 '18 at 20:08














1












1








1





$begingroup$

Here is how to plot the density function of $N(0,1)$:
$$
f(x) = frac{e^{-frac{x^2}{2}}}{sqrt{2 pi}} .
$$



In Mathematica, a one-liner:



Plot[PDF[NormalDistribution, x], {x, -4, 4}]


enter image description here



In Python, slightly more verbose:



import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-4, 4, 101)
y = np.exp(-x*x/2) / np.sqrt(2*np.pi)

plt.plot(x, y)
plt.show()


enter image description here






share|cite|improve this answer









$endgroup$



Here is how to plot the density function of $N(0,1)$:
$$
f(x) = frac{e^{-frac{x^2}{2}}}{sqrt{2 pi}} .
$$



In Mathematica, a one-liner:



Plot[PDF[NormalDistribution, x], {x, -4, 4}]


enter image description here



In Python, slightly more verbose:



import numpy as np
import matplotlib.pyplot as plt

x = np.linspace(-4, 4, 101)
y = np.exp(-x*x/2) / np.sqrt(2*np.pi)

plt.plot(x, y)
plt.show()


enter image description here







share|cite|improve this answer












share|cite|improve this answer



share|cite|improve this answer










answered Dec 20 '18 at 19:49









FedericoFederico

5,124514




5,124514












  • $begingroup$
    Thank you, Federico! How can I get the N(0,1) if there are mean and variance which depend on the number of elements?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 19:56










  • $begingroup$
    Translate and rescale: if $Zsim N(mu,sigma)$, then $(Z-mu)/sigmasim N(0,1)$.
    $endgroup$
    – Federico
    Dec 20 '18 at 19:58










  • $begingroup$
    Could you add the figures here for mean=n(n-1)/4, variance=(2n^3+3n^2-5n)/72 at n=10, 100, 1000?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:04










  • $begingroup$
    They don't look any different from the one I plotted. They are just translated and stretched. Only the numbers on the axes change
    $endgroup$
    – Federico
    Dec 20 '18 at 20:08


















  • $begingroup$
    Thank you, Federico! How can I get the N(0,1) if there are mean and variance which depend on the number of elements?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 19:56










  • $begingroup$
    Translate and rescale: if $Zsim N(mu,sigma)$, then $(Z-mu)/sigmasim N(0,1)$.
    $endgroup$
    – Federico
    Dec 20 '18 at 19:58










  • $begingroup$
    Could you add the figures here for mean=n(n-1)/4, variance=(2n^3+3n^2-5n)/72 at n=10, 100, 1000?
    $endgroup$
    – Mikhail Gaichenkov
    Dec 20 '18 at 20:04










  • $begingroup$
    They don't look any different from the one I plotted. They are just translated and stretched. Only the numbers on the axes change
    $endgroup$
    – Federico
    Dec 20 '18 at 20:08
















$begingroup$
Thank you, Federico! How can I get the N(0,1) if there are mean and variance which depend on the number of elements?
$endgroup$
– Mikhail Gaichenkov
Dec 20 '18 at 19:56




$begingroup$
Thank you, Federico! How can I get the N(0,1) if there are mean and variance which depend on the number of elements?
$endgroup$
– Mikhail Gaichenkov
Dec 20 '18 at 19:56












$begingroup$
Translate and rescale: if $Zsim N(mu,sigma)$, then $(Z-mu)/sigmasim N(0,1)$.
$endgroup$
– Federico
Dec 20 '18 at 19:58




$begingroup$
Translate and rescale: if $Zsim N(mu,sigma)$, then $(Z-mu)/sigmasim N(0,1)$.
$endgroup$
– Federico
Dec 20 '18 at 19:58












$begingroup$
Could you add the figures here for mean=n(n-1)/4, variance=(2n^3+3n^2-5n)/72 at n=10, 100, 1000?
$endgroup$
– Mikhail Gaichenkov
Dec 20 '18 at 20:04




$begingroup$
Could you add the figures here for mean=n(n-1)/4, variance=(2n^3+3n^2-5n)/72 at n=10, 100, 1000?
$endgroup$
– Mikhail Gaichenkov
Dec 20 '18 at 20:04












$begingroup$
They don't look any different from the one I plotted. They are just translated and stretched. Only the numbers on the axes change
$endgroup$
– Federico
Dec 20 '18 at 20:08




$begingroup$
They don't look any different from the one I plotted. They are just translated and stretched. Only the numbers on the axes change
$endgroup$
– Federico
Dec 20 '18 at 20:08


















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematics Stack Exchange!


  • 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.


Use MathJax to format equations. MathJax reference.


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%2fmath.stackexchange.com%2fquestions%2f3047905%2fhow-to-plot-the-normal-distribution%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

Plaza Victoria

In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...