Probability of z > 1.28: Visualizing the Gaussian Curve

  • #1

karush

Gold Member
MHB
3,264
4
ok I was able to get the graph of P(z>1.28)

\begin{tikzpicture}
%preamble \usepackage{pgfplots}
\newcommand\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))} % Gauss function, parameters mu and sigma
\begin{axis}[every axis plot post/.append style={
mark=none,samples=50,smooth}, % All plots: 50 samples, smooth, no marks
axis x line*=bottom, % no box around the plot, only x axis
axis y line=none, % the * suppresses the arrow tips
enlargelimits=upper, % extend the axes a bit to the right and top
domain=-4:4] % Default for all plots: from -4:4
%\node [below] at (1.28,0) {$a$};%
\addplot [fill=cyan!30, draw=none, domain=1.28:4] {\gauss{0}{1}} \closedcycle;
\addplot {\gauss{0}{1}};
\end{axis}
\end{tikzpicture}

but... most guass curves i see are about half this high
and usually only the domain ticks are shown
in this case only 1.28 needs be shown
really don't need what is here on the x-axis
since is basically already understood

also this code was c/p from Overleaf which is very common Latex editor among Universities

MHB has been a great help on this
 
Last edited:

Answers and Replies

  • #2
We can set custom tick marks and/or labels with xtick respectively xticklabels.
And we can change the height with height, in which case we will also want to set the width because otherwise the picture is just scaled.

If we do so, we get:
Code:
\begin{tikzpicture}
%preamble \usepackage{pgfplots}
\newcommand\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))} % Gauss function, parameters mu and sigma
\begin{axis}[every axis plot post/.append style={
  mark=none,samples=50,smooth}, % All plots: 50 samples, smooth, no marks
axis x line*=bottom, % no box around the plot, only x axis
axis y line=none, % the * suppresses the arrow tips
enlargelimits=upper, % extend the axes a bit to the right and top
domain=-4:4, % Default for all plots: from -4:4
xtick={1.28},
xticklabels={$a$},
width=10cm,
height=4cm
]
\addplot [fill=cyan!30, draw=none, domain=1.28:4] {\gauss{0}{1}} \closedcycle;
\addplot {\gauss{0}{1}};
\end{axis}
\end{tikzpicture}
\begin{tikzpicture}
%preamble \usepackage{pgfplots}
\newcommand\gauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))} % Gauss function, parameters mu and sigma
\begin{axis}[every axis plot post/.append style={
mark=none,samples=50,smooth}, % All plots: 50 samples, smooth, no marks
axis x line*=bottom, % no box around the plot, only x axis
axis y line=none, % the * suppresses the arrow tips
enlargelimits=upper, % extend the axes a bit to the right and top
domain=-4:4, % Default for all plots: from -4:4
xtick={1.28},
xticklabels={$a$},
width=10cm,
height=4cm
]
\addplot [fill=cyan!30, draw=none, domain=1.28:4] {\gauss{0}{1}} \closedcycle;
\addplot {\gauss{0}{1}};
\end{axis}
\end{tikzpicture}
 
  • #3
that looks great

i went all over the place to find help with this graph
but the one stop help was here at MHB:cool:
 

Suggested for: Probability of z > 1.28: Visualizing the Gaussian Curve

Replies
7
Views
584
Replies
2
Views
933
Replies
5
Views
1K
Replies
1
Views
601
Replies
17
Views
819
Replies
0
Views
843
Replies
0
Views
1K
Back
Top