Asymmetric distribution, Gauss curve
I want to create a positive and negative asymmetric distribution, as shown in the image, it will be possible to include the data (values) one by one to give the desired curve.
The WME is
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
begin{document}
newcommandgauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}
begin{tikzpicture}[
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[every axis plot post/.append style={
mark=none,domain=-3.:3.,samples=100},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue] {gauss{0.}{1.}};
node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (axis description cs:0.5,0) -- (axis description cs:0.5,0.92);
end{axis}
end{tikzpicture}
end{document}
tikz-pgf gauss
add a comment |
I want to create a positive and negative asymmetric distribution, as shown in the image, it will be possible to include the data (values) one by one to give the desired curve.
The WME is
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
begin{document}
newcommandgauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}
begin{tikzpicture}[
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[every axis plot post/.append style={
mark=none,domain=-3.:3.,samples=100},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue] {gauss{0.}{1.}};
node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (axis description cs:0.5,0) -- (axis description cs:0.5,0.92);
end{axis}
end{tikzpicture}
end{document}
tikz-pgf gauss
add a comment |
I want to create a positive and negative asymmetric distribution, as shown in the image, it will be possible to include the data (values) one by one to give the desired curve.
The WME is
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
begin{document}
newcommandgauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}
begin{tikzpicture}[
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[every axis plot post/.append style={
mark=none,domain=-3.:3.,samples=100},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue] {gauss{0.}{1.}};
node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (axis description cs:0.5,0) -- (axis description cs:0.5,0.92);
end{axis}
end{tikzpicture}
end{document}
tikz-pgf gauss
I want to create a positive and negative asymmetric distribution, as shown in the image, it will be possible to include the data (values) one by one to give the desired curve.
The WME is
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
begin{document}
newcommandgauss[2]{1/(#2*sqrt(2*pi))*exp(-((x-#1)^2)/(2*#2^2))}
begin{tikzpicture}[
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[every axis plot post/.append style={
mark=none,domain=-3.:3.,samples=100},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue] {gauss{0.}{1.}};
node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (axis description cs:0.5,0) -- (axis description cs:0.5,0.92);
end{axis}
end{tikzpicture}
end{document}
tikz-pgf gauss
tikz-pgf gauss
asked Nov 26 '18 at 2:34
Samuel Diaz
28628
28628
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
This is only a partial answer since it is not clear to me what an asymmetric Gauss curve precisely is. This is more to discuss how to set this up in principle. So I am only going to discuss how to plot a deformed Gauss curve.
To this end, I'd like to convince you to use declare function rather than the definition you use. In the example below, I am going to use
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));
Here Gauss reduces to an ordinary Gaussian for u=0, where x is just the variable, y defines the location of the maximum and z the width. If you turn on a nontrivial u, the Gaussian will get deformed.
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
pgfplotsset{height=4cm,width=8cm,compat=1.16}
begin{document}
begin{tikzpicture}[font=sffamily,
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));},
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[
every axis plot post/.append style={
mark=none,samples=101},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue,domain=-1:3] {Gauss(x,0,0.6,-0.4)};
draw[line width=1.5pt,dashed, black] (0,0) -- (0,{Gauss(0,0,0.6,-0.4)});
%node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (0.6,0) -- (0.6,{Gauss(0.6,0,0.6,-0.4)});
draw[line width=1.5pt,dashed, red] (-0.6,0) -- (-0.6,{Gauss(-0.6,0,0.6,-0.4)});
path (-0.6,0) coordinate (ML) (0.6,0) coordinate (MR) (0,0) coordinate (MM);
end{axis}
draw[latex-] (ML) to[out=-90,in=45] ++ (-0.6,-0.6) node[below left,inner
sep=1pt]{$langle Xrangle-Delta$};
draw[latex-] (MR) to[out=-90,in=135] ++ (0.6,-0.6) node[below right,inner
sep=1pt]{$langle Xrangle+Delta$};
draw[latex-] (MM) --++ (0,-0.6) node[below,inner
sep=1pt]{$langle Xrangle$};
end{tikzpicture}
end{document}

@ marmot They are two separate graphs, one that leans to the right and the other to the left, known as negative skew and positive skew. en.wikipedia.org/wiki/Skewness
– Samuel Diaz
Nov 26 '18 at 3:25
@SamuelDiaz Thanks for the link! But as far as I can see it does not really give you a unique parametrization of these deformed Gaussians, does it?
– marmot
Nov 26 '18 at 3:59
Correct, you have to keep in mind that you meet that average < average < mode or average > median > fashion.
– Samuel Diaz
Nov 26 '18 at 4:09
@SamuelDiaz I added a possible way how you could use this.
– marmot
Nov 26 '18 at 4:33
add a comment |
Probably slightly overkill and certainly not efficient, but you could try an approximate skew normal (central tendencies are omitted below):
documentclass[border=5, tikz]{standalone}
usetikzlibrary{math}
usepackage{pgfplots}
pgfplotsset{compat=1.14}
tikzmath{%
function h1(x, lx) { return (9*lx + 3*((lx)^2) + ((lx)^3)/3 + 9); };
function h2(x, lx) { return (3*lx - ((lx)^3)/3 + 4); };
function h3(x, lx) { return (9*lx - 3*((lx)^2) + ((lx)^3)/3 + 7); };
function skewnorm(x, l) {
x = (l < 0) ? -x : x;
l = abs(l);
e = exp(-(x^2)/2);
return (l == 0) ? 1 / sqrt(2 * pi) * e: (
(x < -3/l) ? 0 : (
(x < -1/l) ? e / (8 * sqrt(2 * pi)) * h1(x, x*l) : (
(x < 1/l) ? e / (4 * sqrt(2 * pi)) * h2(x, x*l) : (
(x < 3/l) ? e / (8 * sqrt(2 * pi)) * h3(x, x*l) : (
sqrt(2/pi) * e)))));
};
}
begin{document}
begin{tikzpicture}[line join=round, line cap=round]
begin{axis}[
width=4in, height=2in,
every axis plot post/.append style={
mark=none, domain=-3.5:3.5, samples=200, very thick
},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0, ymax=0.75,
xtick=empty,]
addplot[red] {skewnorm(x, -4)};
addplot[green] {skewnorm(x, -2)};
addplot[gray] {skewnorm(x, 0)};
addplot[blue] {skewnorm(x, 2)};
addplot[orange] {skewnorm(x, 4)};
legend{$lambda=-4$,$lambda=-2$,$lambda=0$,$lambda=2$,$lambda=4$}
end{axis}
end{tikzpicture}
end{document}

add a comment |
Another possible way (apart from @marmot's answer) is to plot the skewed distribution function is to exploit the chi-square distribution.
For instance:
documentclass{standalone}
usepackage{pgfplots}
%https://en.wikipedia.org/wiki/Chi-squared_distribution
%https://tex.stackexchange.com/questions/120441/plot-the-probability-density-function-of-the-gamma-distribution?rq=1
% the second link gives the numerical approximation of gamma function
begin{document}
begin{tikzpicture}[
declare function={gamma(z)=
(2.506628274631*sqrt(1/z) + 0.20888568*(1/z)^(1.5) + 0.00870357*(1/z)^(2.5) - (174.2106599*(1/z)^(3.5))/25920 - (715.6423511*(1/z)^(4.5))/1244160)*exp((-ln(1/z)-1)*z);},
declare function={chipdf(x,k) = x^(k/2-1)*exp(-x/2) / (2^(k/2)*gamma(k));}
]
begin{axis}[
axis lines=left,
enlargelimits=upper,
]
addplot [smooth, domain=0:20, blue] {chipdf(x,2)};
addplot [smooth, domain=0:20, green] {chipdf(x,3)};
addplot [smooth, domain=0:20, black] {chipdf(x,4)};
addplot [smooth, domain=0:20, cyan] {chipdf(x,5)};
addplot [smooth, domain=0:20, magenta] {chipdf(x,6)};
end{axis}
end{tikzpicture}
end{document}
which will give you:

Using this, you can include your mean-median-mode as lines in the plot.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461758%2fasymmetric-distribution-gauss-curve%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
This is only a partial answer since it is not clear to me what an asymmetric Gauss curve precisely is. This is more to discuss how to set this up in principle. So I am only going to discuss how to plot a deformed Gauss curve.
To this end, I'd like to convince you to use declare function rather than the definition you use. In the example below, I am going to use
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));
Here Gauss reduces to an ordinary Gaussian for u=0, where x is just the variable, y defines the location of the maximum and z the width. If you turn on a nontrivial u, the Gaussian will get deformed.
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
pgfplotsset{height=4cm,width=8cm,compat=1.16}
begin{document}
begin{tikzpicture}[font=sffamily,
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));},
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[
every axis plot post/.append style={
mark=none,samples=101},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue,domain=-1:3] {Gauss(x,0,0.6,-0.4)};
draw[line width=1.5pt,dashed, black] (0,0) -- (0,{Gauss(0,0,0.6,-0.4)});
%node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (0.6,0) -- (0.6,{Gauss(0.6,0,0.6,-0.4)});
draw[line width=1.5pt,dashed, red] (-0.6,0) -- (-0.6,{Gauss(-0.6,0,0.6,-0.4)});
path (-0.6,0) coordinate (ML) (0.6,0) coordinate (MR) (0,0) coordinate (MM);
end{axis}
draw[latex-] (ML) to[out=-90,in=45] ++ (-0.6,-0.6) node[below left,inner
sep=1pt]{$langle Xrangle-Delta$};
draw[latex-] (MR) to[out=-90,in=135] ++ (0.6,-0.6) node[below right,inner
sep=1pt]{$langle Xrangle+Delta$};
draw[latex-] (MM) --++ (0,-0.6) node[below,inner
sep=1pt]{$langle Xrangle$};
end{tikzpicture}
end{document}

@ marmot They are two separate graphs, one that leans to the right and the other to the left, known as negative skew and positive skew. en.wikipedia.org/wiki/Skewness
– Samuel Diaz
Nov 26 '18 at 3:25
@SamuelDiaz Thanks for the link! But as far as I can see it does not really give you a unique parametrization of these deformed Gaussians, does it?
– marmot
Nov 26 '18 at 3:59
Correct, you have to keep in mind that you meet that average < average < mode or average > median > fashion.
– Samuel Diaz
Nov 26 '18 at 4:09
@SamuelDiaz I added a possible way how you could use this.
– marmot
Nov 26 '18 at 4:33
add a comment |
This is only a partial answer since it is not clear to me what an asymmetric Gauss curve precisely is. This is more to discuss how to set this up in principle. So I am only going to discuss how to plot a deformed Gauss curve.
To this end, I'd like to convince you to use declare function rather than the definition you use. In the example below, I am going to use
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));
Here Gauss reduces to an ordinary Gaussian for u=0, where x is just the variable, y defines the location of the maximum and z the width. If you turn on a nontrivial u, the Gaussian will get deformed.
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
pgfplotsset{height=4cm,width=8cm,compat=1.16}
begin{document}
begin{tikzpicture}[font=sffamily,
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));},
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[
every axis plot post/.append style={
mark=none,samples=101},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue,domain=-1:3] {Gauss(x,0,0.6,-0.4)};
draw[line width=1.5pt,dashed, black] (0,0) -- (0,{Gauss(0,0,0.6,-0.4)});
%node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (0.6,0) -- (0.6,{Gauss(0.6,0,0.6,-0.4)});
draw[line width=1.5pt,dashed, red] (-0.6,0) -- (-0.6,{Gauss(-0.6,0,0.6,-0.4)});
path (-0.6,0) coordinate (ML) (0.6,0) coordinate (MR) (0,0) coordinate (MM);
end{axis}
draw[latex-] (ML) to[out=-90,in=45] ++ (-0.6,-0.6) node[below left,inner
sep=1pt]{$langle Xrangle-Delta$};
draw[latex-] (MR) to[out=-90,in=135] ++ (0.6,-0.6) node[below right,inner
sep=1pt]{$langle Xrangle+Delta$};
draw[latex-] (MM) --++ (0,-0.6) node[below,inner
sep=1pt]{$langle Xrangle$};
end{tikzpicture}
end{document}

@ marmot They are two separate graphs, one that leans to the right and the other to the left, known as negative skew and positive skew. en.wikipedia.org/wiki/Skewness
– Samuel Diaz
Nov 26 '18 at 3:25
@SamuelDiaz Thanks for the link! But as far as I can see it does not really give you a unique parametrization of these deformed Gaussians, does it?
– marmot
Nov 26 '18 at 3:59
Correct, you have to keep in mind that you meet that average < average < mode or average > median > fashion.
– Samuel Diaz
Nov 26 '18 at 4:09
@SamuelDiaz I added a possible way how you could use this.
– marmot
Nov 26 '18 at 4:33
add a comment |
This is only a partial answer since it is not clear to me what an asymmetric Gauss curve precisely is. This is more to discuss how to set this up in principle. So I am only going to discuss how to plot a deformed Gauss curve.
To this end, I'd like to convince you to use declare function rather than the definition you use. In the example below, I am going to use
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));
Here Gauss reduces to an ordinary Gaussian for u=0, where x is just the variable, y defines the location of the maximum and z the width. If you turn on a nontrivial u, the Gaussian will get deformed.
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
pgfplotsset{height=4cm,width=8cm,compat=1.16}
begin{document}
begin{tikzpicture}[font=sffamily,
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));},
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[
every axis plot post/.append style={
mark=none,samples=101},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue,domain=-1:3] {Gauss(x,0,0.6,-0.4)};
draw[line width=1.5pt,dashed, black] (0,0) -- (0,{Gauss(0,0,0.6,-0.4)});
%node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (0.6,0) -- (0.6,{Gauss(0.6,0,0.6,-0.4)});
draw[line width=1.5pt,dashed, red] (-0.6,0) -- (-0.6,{Gauss(-0.6,0,0.6,-0.4)});
path (-0.6,0) coordinate (ML) (0.6,0) coordinate (MR) (0,0) coordinate (MM);
end{axis}
draw[latex-] (ML) to[out=-90,in=45] ++ (-0.6,-0.6) node[below left,inner
sep=1pt]{$langle Xrangle-Delta$};
draw[latex-] (MR) to[out=-90,in=135] ++ (0.6,-0.6) node[below right,inner
sep=1pt]{$langle Xrangle+Delta$};
draw[latex-] (MM) --++ (0,-0.6) node[below,inner
sep=1pt]{$langle Xrangle$};
end{tikzpicture}
end{document}

This is only a partial answer since it is not clear to me what an asymmetric Gauss curve precisely is. This is more to discuss how to set this up in principle. So I am only going to discuss how to plot a deformed Gauss curve.
To this end, I'd like to convince you to use declare function rather than the definition you use. In the example below, I am going to use
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));
Here Gauss reduces to an ordinary Gaussian for u=0, where x is just the variable, y defines the location of the maximum and z the width. If you turn on a nontrivial u, the Gaussian will get deformed.
documentclass[border=5mm]{standalone}
usepackage{pgfplots}
pgfplotsset{height=4cm,width=8cm,compat=1.16}
begin{document}
begin{tikzpicture}[font=sffamily,
declare function={Gauss(x,y,z,u)=1/(z*sqrt(2*pi))*exp(-((x-y+u*(x-y)*sign(x-y))^2)/(2*z^2));},
every pin edge/.style={latex-,line width=1.5pt},
every pin/.style={fill=yellow!50,rectangle,rounded corners=3pt,font=small}]
begin{axis}[
every axis plot post/.append style={
mark=none,samples=101},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0,
xtick=empty,]
addplot[line width=1.5pt,blue,domain=-1:3] {Gauss(x,0,0.6,-0.4)};
draw[line width=1.5pt,dashed, black] (0,0) -- (0,{Gauss(0,0,0.6,-0.4)});
%node[pin=270:{$X=M_e=M_o$}] at (axis cs:0,0) {};
draw[line width=1.5pt,dashed, red] (0.6,0) -- (0.6,{Gauss(0.6,0,0.6,-0.4)});
draw[line width=1.5pt,dashed, red] (-0.6,0) -- (-0.6,{Gauss(-0.6,0,0.6,-0.4)});
path (-0.6,0) coordinate (ML) (0.6,0) coordinate (MR) (0,0) coordinate (MM);
end{axis}
draw[latex-] (ML) to[out=-90,in=45] ++ (-0.6,-0.6) node[below left,inner
sep=1pt]{$langle Xrangle-Delta$};
draw[latex-] (MR) to[out=-90,in=135] ++ (0.6,-0.6) node[below right,inner
sep=1pt]{$langle Xrangle+Delta$};
draw[latex-] (MM) --++ (0,-0.6) node[below,inner
sep=1pt]{$langle Xrangle$};
end{tikzpicture}
end{document}

edited Nov 26 '18 at 4:52
answered Nov 26 '18 at 3:06
marmot
88.3k4102190
88.3k4102190
@ marmot They are two separate graphs, one that leans to the right and the other to the left, known as negative skew and positive skew. en.wikipedia.org/wiki/Skewness
– Samuel Diaz
Nov 26 '18 at 3:25
@SamuelDiaz Thanks for the link! But as far as I can see it does not really give you a unique parametrization of these deformed Gaussians, does it?
– marmot
Nov 26 '18 at 3:59
Correct, you have to keep in mind that you meet that average < average < mode or average > median > fashion.
– Samuel Diaz
Nov 26 '18 at 4:09
@SamuelDiaz I added a possible way how you could use this.
– marmot
Nov 26 '18 at 4:33
add a comment |
@ marmot They are two separate graphs, one that leans to the right and the other to the left, known as negative skew and positive skew. en.wikipedia.org/wiki/Skewness
– Samuel Diaz
Nov 26 '18 at 3:25
@SamuelDiaz Thanks for the link! But as far as I can see it does not really give you a unique parametrization of these deformed Gaussians, does it?
– marmot
Nov 26 '18 at 3:59
Correct, you have to keep in mind that you meet that average < average < mode or average > median > fashion.
– Samuel Diaz
Nov 26 '18 at 4:09
@SamuelDiaz I added a possible way how you could use this.
– marmot
Nov 26 '18 at 4:33
@ marmot They are two separate graphs, one that leans to the right and the other to the left, known as negative skew and positive skew. en.wikipedia.org/wiki/Skewness
– Samuel Diaz
Nov 26 '18 at 3:25
@ marmot They are two separate graphs, one that leans to the right and the other to the left, known as negative skew and positive skew. en.wikipedia.org/wiki/Skewness
– Samuel Diaz
Nov 26 '18 at 3:25
@SamuelDiaz Thanks for the link! But as far as I can see it does not really give you a unique parametrization of these deformed Gaussians, does it?
– marmot
Nov 26 '18 at 3:59
@SamuelDiaz Thanks for the link! But as far as I can see it does not really give you a unique parametrization of these deformed Gaussians, does it?
– marmot
Nov 26 '18 at 3:59
Correct, you have to keep in mind that you meet that average < average < mode or average > median > fashion.
– Samuel Diaz
Nov 26 '18 at 4:09
Correct, you have to keep in mind that you meet that average < average < mode or average > median > fashion.
– Samuel Diaz
Nov 26 '18 at 4:09
@SamuelDiaz I added a possible way how you could use this.
– marmot
Nov 26 '18 at 4:33
@SamuelDiaz I added a possible way how you could use this.
– marmot
Nov 26 '18 at 4:33
add a comment |
Probably slightly overkill and certainly not efficient, but you could try an approximate skew normal (central tendencies are omitted below):
documentclass[border=5, tikz]{standalone}
usetikzlibrary{math}
usepackage{pgfplots}
pgfplotsset{compat=1.14}
tikzmath{%
function h1(x, lx) { return (9*lx + 3*((lx)^2) + ((lx)^3)/3 + 9); };
function h2(x, lx) { return (3*lx - ((lx)^3)/3 + 4); };
function h3(x, lx) { return (9*lx - 3*((lx)^2) + ((lx)^3)/3 + 7); };
function skewnorm(x, l) {
x = (l < 0) ? -x : x;
l = abs(l);
e = exp(-(x^2)/2);
return (l == 0) ? 1 / sqrt(2 * pi) * e: (
(x < -3/l) ? 0 : (
(x < -1/l) ? e / (8 * sqrt(2 * pi)) * h1(x, x*l) : (
(x < 1/l) ? e / (4 * sqrt(2 * pi)) * h2(x, x*l) : (
(x < 3/l) ? e / (8 * sqrt(2 * pi)) * h3(x, x*l) : (
sqrt(2/pi) * e)))));
};
}
begin{document}
begin{tikzpicture}[line join=round, line cap=round]
begin{axis}[
width=4in, height=2in,
every axis plot post/.append style={
mark=none, domain=-3.5:3.5, samples=200, very thick
},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0, ymax=0.75,
xtick=empty,]
addplot[red] {skewnorm(x, -4)};
addplot[green] {skewnorm(x, -2)};
addplot[gray] {skewnorm(x, 0)};
addplot[blue] {skewnorm(x, 2)};
addplot[orange] {skewnorm(x, 4)};
legend{$lambda=-4$,$lambda=-2$,$lambda=0$,$lambda=2$,$lambda=4$}
end{axis}
end{tikzpicture}
end{document}

add a comment |
Probably slightly overkill and certainly not efficient, but you could try an approximate skew normal (central tendencies are omitted below):
documentclass[border=5, tikz]{standalone}
usetikzlibrary{math}
usepackage{pgfplots}
pgfplotsset{compat=1.14}
tikzmath{%
function h1(x, lx) { return (9*lx + 3*((lx)^2) + ((lx)^3)/3 + 9); };
function h2(x, lx) { return (3*lx - ((lx)^3)/3 + 4); };
function h3(x, lx) { return (9*lx - 3*((lx)^2) + ((lx)^3)/3 + 7); };
function skewnorm(x, l) {
x = (l < 0) ? -x : x;
l = abs(l);
e = exp(-(x^2)/2);
return (l == 0) ? 1 / sqrt(2 * pi) * e: (
(x < -3/l) ? 0 : (
(x < -1/l) ? e / (8 * sqrt(2 * pi)) * h1(x, x*l) : (
(x < 1/l) ? e / (4 * sqrt(2 * pi)) * h2(x, x*l) : (
(x < 3/l) ? e / (8 * sqrt(2 * pi)) * h3(x, x*l) : (
sqrt(2/pi) * e)))));
};
}
begin{document}
begin{tikzpicture}[line join=round, line cap=round]
begin{axis}[
width=4in, height=2in,
every axis plot post/.append style={
mark=none, domain=-3.5:3.5, samples=200, very thick
},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0, ymax=0.75,
xtick=empty,]
addplot[red] {skewnorm(x, -4)};
addplot[green] {skewnorm(x, -2)};
addplot[gray] {skewnorm(x, 0)};
addplot[blue] {skewnorm(x, 2)};
addplot[orange] {skewnorm(x, 4)};
legend{$lambda=-4$,$lambda=-2$,$lambda=0$,$lambda=2$,$lambda=4$}
end{axis}
end{tikzpicture}
end{document}

add a comment |
Probably slightly overkill and certainly not efficient, but you could try an approximate skew normal (central tendencies are omitted below):
documentclass[border=5, tikz]{standalone}
usetikzlibrary{math}
usepackage{pgfplots}
pgfplotsset{compat=1.14}
tikzmath{%
function h1(x, lx) { return (9*lx + 3*((lx)^2) + ((lx)^3)/3 + 9); };
function h2(x, lx) { return (3*lx - ((lx)^3)/3 + 4); };
function h3(x, lx) { return (9*lx - 3*((lx)^2) + ((lx)^3)/3 + 7); };
function skewnorm(x, l) {
x = (l < 0) ? -x : x;
l = abs(l);
e = exp(-(x^2)/2);
return (l == 0) ? 1 / sqrt(2 * pi) * e: (
(x < -3/l) ? 0 : (
(x < -1/l) ? e / (8 * sqrt(2 * pi)) * h1(x, x*l) : (
(x < 1/l) ? e / (4 * sqrt(2 * pi)) * h2(x, x*l) : (
(x < 3/l) ? e / (8 * sqrt(2 * pi)) * h3(x, x*l) : (
sqrt(2/pi) * e)))));
};
}
begin{document}
begin{tikzpicture}[line join=round, line cap=round]
begin{axis}[
width=4in, height=2in,
every axis plot post/.append style={
mark=none, domain=-3.5:3.5, samples=200, very thick
},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0, ymax=0.75,
xtick=empty,]
addplot[red] {skewnorm(x, -4)};
addplot[green] {skewnorm(x, -2)};
addplot[gray] {skewnorm(x, 0)};
addplot[blue] {skewnorm(x, 2)};
addplot[orange] {skewnorm(x, 4)};
legend{$lambda=-4$,$lambda=-2$,$lambda=0$,$lambda=2$,$lambda=4$}
end{axis}
end{tikzpicture}
end{document}

Probably slightly overkill and certainly not efficient, but you could try an approximate skew normal (central tendencies are omitted below):
documentclass[border=5, tikz]{standalone}
usetikzlibrary{math}
usepackage{pgfplots}
pgfplotsset{compat=1.14}
tikzmath{%
function h1(x, lx) { return (9*lx + 3*((lx)^2) + ((lx)^3)/3 + 9); };
function h2(x, lx) { return (3*lx - ((lx)^3)/3 + 4); };
function h3(x, lx) { return (9*lx - 3*((lx)^2) + ((lx)^3)/3 + 7); };
function skewnorm(x, l) {
x = (l < 0) ? -x : x;
l = abs(l);
e = exp(-(x^2)/2);
return (l == 0) ? 1 / sqrt(2 * pi) * e: (
(x < -3/l) ? 0 : (
(x < -1/l) ? e / (8 * sqrt(2 * pi)) * h1(x, x*l) : (
(x < 1/l) ? e / (4 * sqrt(2 * pi)) * h2(x, x*l) : (
(x < 3/l) ? e / (8 * sqrt(2 * pi)) * h3(x, x*l) : (
sqrt(2/pi) * e)))));
};
}
begin{document}
begin{tikzpicture}[line join=round, line cap=round]
begin{axis}[
width=4in, height=2in,
every axis plot post/.append style={
mark=none, domain=-3.5:3.5, samples=200, very thick
},
clip=false,
axis y line=none,
axis x line*=bottom,
ymin=0, ymax=0.75,
xtick=empty,]
addplot[red] {skewnorm(x, -4)};
addplot[green] {skewnorm(x, -2)};
addplot[gray] {skewnorm(x, 0)};
addplot[blue] {skewnorm(x, 2)};
addplot[orange] {skewnorm(x, 4)};
legend{$lambda=-4$,$lambda=-2$,$lambda=0$,$lambda=2$,$lambda=4$}
end{axis}
end{tikzpicture}
end{document}

answered Nov 26 '18 at 16:02
Mark Wibrow
61.6k4112176
61.6k4112176
add a comment |
add a comment |
Another possible way (apart from @marmot's answer) is to plot the skewed distribution function is to exploit the chi-square distribution.
For instance:
documentclass{standalone}
usepackage{pgfplots}
%https://en.wikipedia.org/wiki/Chi-squared_distribution
%https://tex.stackexchange.com/questions/120441/plot-the-probability-density-function-of-the-gamma-distribution?rq=1
% the second link gives the numerical approximation of gamma function
begin{document}
begin{tikzpicture}[
declare function={gamma(z)=
(2.506628274631*sqrt(1/z) + 0.20888568*(1/z)^(1.5) + 0.00870357*(1/z)^(2.5) - (174.2106599*(1/z)^(3.5))/25920 - (715.6423511*(1/z)^(4.5))/1244160)*exp((-ln(1/z)-1)*z);},
declare function={chipdf(x,k) = x^(k/2-1)*exp(-x/2) / (2^(k/2)*gamma(k));}
]
begin{axis}[
axis lines=left,
enlargelimits=upper,
]
addplot [smooth, domain=0:20, blue] {chipdf(x,2)};
addplot [smooth, domain=0:20, green] {chipdf(x,3)};
addplot [smooth, domain=0:20, black] {chipdf(x,4)};
addplot [smooth, domain=0:20, cyan] {chipdf(x,5)};
addplot [smooth, domain=0:20, magenta] {chipdf(x,6)};
end{axis}
end{tikzpicture}
end{document}
which will give you:

Using this, you can include your mean-median-mode as lines in the plot.
add a comment |
Another possible way (apart from @marmot's answer) is to plot the skewed distribution function is to exploit the chi-square distribution.
For instance:
documentclass{standalone}
usepackage{pgfplots}
%https://en.wikipedia.org/wiki/Chi-squared_distribution
%https://tex.stackexchange.com/questions/120441/plot-the-probability-density-function-of-the-gamma-distribution?rq=1
% the second link gives the numerical approximation of gamma function
begin{document}
begin{tikzpicture}[
declare function={gamma(z)=
(2.506628274631*sqrt(1/z) + 0.20888568*(1/z)^(1.5) + 0.00870357*(1/z)^(2.5) - (174.2106599*(1/z)^(3.5))/25920 - (715.6423511*(1/z)^(4.5))/1244160)*exp((-ln(1/z)-1)*z);},
declare function={chipdf(x,k) = x^(k/2-1)*exp(-x/2) / (2^(k/2)*gamma(k));}
]
begin{axis}[
axis lines=left,
enlargelimits=upper,
]
addplot [smooth, domain=0:20, blue] {chipdf(x,2)};
addplot [smooth, domain=0:20, green] {chipdf(x,3)};
addplot [smooth, domain=0:20, black] {chipdf(x,4)};
addplot [smooth, domain=0:20, cyan] {chipdf(x,5)};
addplot [smooth, domain=0:20, magenta] {chipdf(x,6)};
end{axis}
end{tikzpicture}
end{document}
which will give you:

Using this, you can include your mean-median-mode as lines in the plot.
add a comment |
Another possible way (apart from @marmot's answer) is to plot the skewed distribution function is to exploit the chi-square distribution.
For instance:
documentclass{standalone}
usepackage{pgfplots}
%https://en.wikipedia.org/wiki/Chi-squared_distribution
%https://tex.stackexchange.com/questions/120441/plot-the-probability-density-function-of-the-gamma-distribution?rq=1
% the second link gives the numerical approximation of gamma function
begin{document}
begin{tikzpicture}[
declare function={gamma(z)=
(2.506628274631*sqrt(1/z) + 0.20888568*(1/z)^(1.5) + 0.00870357*(1/z)^(2.5) - (174.2106599*(1/z)^(3.5))/25920 - (715.6423511*(1/z)^(4.5))/1244160)*exp((-ln(1/z)-1)*z);},
declare function={chipdf(x,k) = x^(k/2-1)*exp(-x/2) / (2^(k/2)*gamma(k));}
]
begin{axis}[
axis lines=left,
enlargelimits=upper,
]
addplot [smooth, domain=0:20, blue] {chipdf(x,2)};
addplot [smooth, domain=0:20, green] {chipdf(x,3)};
addplot [smooth, domain=0:20, black] {chipdf(x,4)};
addplot [smooth, domain=0:20, cyan] {chipdf(x,5)};
addplot [smooth, domain=0:20, magenta] {chipdf(x,6)};
end{axis}
end{tikzpicture}
end{document}
which will give you:

Using this, you can include your mean-median-mode as lines in the plot.
Another possible way (apart from @marmot's answer) is to plot the skewed distribution function is to exploit the chi-square distribution.
For instance:
documentclass{standalone}
usepackage{pgfplots}
%https://en.wikipedia.org/wiki/Chi-squared_distribution
%https://tex.stackexchange.com/questions/120441/plot-the-probability-density-function-of-the-gamma-distribution?rq=1
% the second link gives the numerical approximation of gamma function
begin{document}
begin{tikzpicture}[
declare function={gamma(z)=
(2.506628274631*sqrt(1/z) + 0.20888568*(1/z)^(1.5) + 0.00870357*(1/z)^(2.5) - (174.2106599*(1/z)^(3.5))/25920 - (715.6423511*(1/z)^(4.5))/1244160)*exp((-ln(1/z)-1)*z);},
declare function={chipdf(x,k) = x^(k/2-1)*exp(-x/2) / (2^(k/2)*gamma(k));}
]
begin{axis}[
axis lines=left,
enlargelimits=upper,
]
addplot [smooth, domain=0:20, blue] {chipdf(x,2)};
addplot [smooth, domain=0:20, green] {chipdf(x,3)};
addplot [smooth, domain=0:20, black] {chipdf(x,4)};
addplot [smooth, domain=0:20, cyan] {chipdf(x,5)};
addplot [smooth, domain=0:20, magenta] {chipdf(x,6)};
end{axis}
end{tikzpicture}
end{document}
which will give you:

Using this, you can include your mean-median-mode as lines in the plot.
answered Nov 26 '18 at 7:19
Raaja
2,1722630
2,1722630
add a comment |
add a comment |
Thanks for contributing an answer to TeX - LaTeX 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.
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f461758%2fasymmetric-distribution-gauss-curve%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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