Gaussian Probability: 1 to 2 in tikz

In summary, Desmos does not have a function that calculates the area below the Gaussian graph. And it cannot calculate the integral of a function either.
  • #1
karush
Gold Member
MHB
3,269
5
\begin{tikzpicture}[scale=0.6]
%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,2},
xticklabels={$1$,$2$},
width=10cm,
height=4cm]
\addplot [fill=cyan!30, draw=none, domain=1:2] {\gauss{0}{1}} \closedcycle;
\addplot {\gauss{0}{1}};
\end{axis}
\end{tikzpicture}

ok this was for P(1<z<2) scaled the graph to .6
the ultimate answer of course is the area in the domain which I don't know if we can derive from the gauss{}{} function
I tried to put the newcommand quass{}{} in the preamble of Overleaf but it didn't take
also thot since all 12 of homework problem are just graphing P()
be nice just have a newcommand \Pg with arguments but also need code that can be colabortive with Overleaf and MHB

again mega mahalo for all the help
 
Physics news on Phys.org
  • #2
this is what it looks like in Overleaf...

Screenshot 2021-08-13 11.20.21 AM.png
 
  • #3
I'm afraid that TikZ is not an advanced calculator.
It does not have a function that calculates the area below the Gaussian graph.
And it cannot calculate the integral of a function either.
 
  • #4
ok well that seems to an advantage of desmos over tikz except tikz is much more exotic
 
Last edited:
  • #5
karush said:
ok well that seem to an advantage of desmos over tikz except tikz is much more exotic
It appears I misunderstood your question somehow.
Desmos does not have such ability either.
Can you clarify what you want?
 
  • #6
well i have graph i wanted
i was just curious about integration function in tikx

but yes desmos has a integration function its under misc in the function menu
i have used it many times
 
  • #7
Well, with a bit of trickery, we can do:
\begin{tikzpicture}[scale=1,
declare function={
gauss(\x,\mean,\sigma) = 1/(\sigma*sqrt(2*pi))*exp(-(\x-\mean)^2/(2*\sigma^2));
normcdf(\x,\m,\s)=1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));
},
]
%preamble \usepackage{pgfplots}
\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,2},
width=10cm,
height=4cm]
\addplot [fill=cyan!30, draw=none, domain=1:2] {gauss(x,0,1)} \closedcycle;
\addplot {gauss(x,0,1)};
\path foreach \y [evaluate=\y as \yeval using {normcdf(\y,0,1)-normcdf(1,0,1)}] in {2} { node[ left ] at (axis cs:{\y},0.05) {\yeval} };
\end{axis}
\end{tikzpicture}

It uses
Code:
[declare function={
    normcdf(\x,\m,\s)=1/(1 + exp(-0.07056*((\x-\m)/\s)^3 - 1.5976*(\x-\m)/\s));
}]
to approximate the area under the Gaussian graph.

And it uses evaluate=\y as \yeval using syntax to convert the function call into a value before printing it.
 
  • #8
wow that is pretty cool...
 

What is Gaussian Probability?

Gaussian Probability, also known as normal distribution, is a statistical concept that describes the probability of a continuous random variable falling within a certain range of values. It follows a bell-shaped curve and is widely used in various fields of science, including physics, biology, and economics.

How is Gaussian Probability represented?

In tikz, Gaussian Probability is often represented graphically using a bell-shaped curve, where the x-axis represents the range of values and the y-axis represents the probability of each value occurring. The curve is symmetrical and centered around the mean, with the highest point corresponding to the mean value.

What is the formula for calculating Gaussian Probability?

The formula for Gaussian Probability is given by P(x) = (1/σ√2π)e-(x-μ)²/2σ², where x is the variable value, μ is the mean, and σ is the standard deviation. This formula can be used to calculate the probability of any value falling within a given range in a normal distribution.

What are some real-life applications of Gaussian Probability?

Gaussian Probability is used in various fields for data analysis and prediction, including weather forecasting, stock market analysis, and risk management. It is also used in quality control to determine the likelihood of a product meeting certain specifications. Additionally, it is used in medical research to analyze and interpret data from experiments and clinical trials.

How does the Central Limit Theorem relate to Gaussian Probability?

The Central Limit Theorem states that the sum of a large number of independent and identically distributed random variables will tend towards a normal distribution, regardless of the underlying distribution. This means that many natural phenomena can be modeled using Gaussian Probability, making it a fundamental concept in statistics and data analysis.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
884
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
738
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
2K
  • Poll
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
Back
Top