MHB Normal distribution graph P(a<x<b)

Click For Summary
SUMMARY

The discussion focuses on plotting a normal distribution graph using TikZ in LaTeX, specifically to visualize the probability that the lifespan of a certain insect species falls between 55 and 60 hours. The values for a and b are calculated as a = 0.455 and b = 0.682, derived from the lifespan data. Users encountered issues with rendering the graph in Overleaf and identified the absence of the \begin{tikzpicture} command as a key error in their code. The term "normcdf" was also mentioned, prompting questions about its relevance to MATLAB.

PREREQUISITES
  • Understanding of normal distribution concepts
  • Familiarity with LaTeX and TikZ for plotting
  • Basic knowledge of probability calculations
  • Experience with Overleaf for LaTeX document preparation
NEXT STEPS
  • Learn how to use TikZ for advanced plotting in LaTeX
  • Explore the normcdf function in MATLAB for probability calculations
  • Study the properties of normal distributions and their applications
  • Practice rendering complex graphs in Overleaf with TikZ
USEFUL FOR

Students, educators, and researchers in statistics, mathematics, and data visualization who are looking to enhance their skills in plotting normal distributions using LaTeX and TikZ.

karush
Gold Member
MHB
Messages
3,240
Reaction score
5
The probability that the lifespan of an insect of this species lies between 55 and 60 hours is represented by the shaded area in the following diagram.\\
Write down the values of a and b.
$a=\dfrac{2}{4.4}= 0.455 b=\dfrac{3}{4.4}=0.682]$

ok this was a key to a test question from 2013 but mostly I wanted to use tikz to plot the graph
also not real sure why they used the calculation they did 2 and 3 ?

no sure why this did not render here it was fine in Overleaf
also not sure even if the graph is correct
also the word noramcdf showed up on the PDF is that a mathlab or something:rolleyes:

%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=-2:3, % Default for all plots: from -4:4
xtick={-.455,.655},
xticklabels={$-.455$,$.655$},
width=10cm,
height=4cm]
\addplot [fill=gray!30, draw=none, domain=-0.45:0.655] {\gauss{-0.455}{0.655}} \closedcycle;
\addplot {\gauss{-0.455}{0.655}};
\end{axis}
\end{tikzpicture}

Screenshot 2021-09-04 12.34.59 PM.png
 
Last edited:
Physics news on Phys.org
It's because \begin{tikzpicture} is missing at the beginning.
When we add it, we get:
\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=-2:3, % Default for all plots: from -4:4
xtick={-.455,.655},
xticklabels={$-.455$,$.655$},
width=10cm,
height=4cm]
\addplot [fill=gray!30, draw=none, domain=-0.45:0.655] {\gauss{-0.455}{0.655}} \closedcycle;
\addplot {\gauss{-0.455}{0.655}};
\end{axis}
\end{tikzpicture}
 
I should of seen that,,,,ok I added to the OP
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
Replies
5
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • Poll Poll
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
6
Views
2K
  • · Replies 0 ·
Replies
0
Views
6K