答案1
正如 Bobyandbob 在在问题下方评论你可以采纳我的答案这里得到你所需要的。
总结一下那里给出的内容:
如果您已经安装,gnuplot
您可以使用 PGFPlotsraw gnuplot
函数来定义 beta 函数所需的函数,然后绘制由 PGFPlots 读取并用于绘图的数据文件。
% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
% define a command which stores all commands that are needed for every
% `raw gnuplot' call
\newcommand*\GnuplotDefs{
% set number of samples
set samples 51;
%
% define beta distribution function
% (copied from <http://gnuplot.sourceforge.net/demo/prob.5.gnu>)
Binv(p,q)=exp(lgamma(p+q)-lgamma(p)-lgamma(q));
beta(x,p,q)=p<=0||q<=0?1/0:x<0||x>1?0.0:Binv(p,q)*x**(p-1.0)*(1.0-x)**(q-1.0);
}
\begin{document}
\begin{tikzpicture}
% define macros which are needed for the axis limits as well as for
% setting the domain of calculation
\pgfmathsetmacro{\xmin}{0}
\pgfmathsetmacro{\xmax}{1}
\begin{axis}[
xmin=\xmin,
xmax=\xmax,
no markers,
]
\addplot gnuplot [raw gnuplot] {
% first call all the "common" definitions
\GnuplotDefs
% and then create the data tables
% in GnuPlot `x` key is identical to PGFPlots `domain` key
%
% "plot" beta function
plot [x=\xmin:\xmax] beta(x,1,1);
};
\addplot gnuplot [raw gnuplot] {
\GnuplotDefs
plot [x=\xmin:\xmax] beta(x,7,5);
};
\end{axis}
\end{tikzpicture}
\end{document}
答案2
pstricks
一个带有及其模块的短代码pst-func
,它定义了一个命令(使用开关(MiKTeX)或(TeX Live、MacTeX)\psBetaDist
进行编译):pdflatex
--enable-write18
-shell-escape
\documentclass[x11names, border=1pt]{standalone}
\usepackage{pst-func, pst-plot}
\usepackage{auto-pst-pdf}
\begin{document}
\psset{xunit=8cm, yunit=2cm}
\begin{pspicture*}(-1,-1)(1.1,3.1)
\psaxes[linecolor=LightSteelBlue3, tickcolor=LightSteelBlue3, ticksize=3pt -3pt, ticks=all, tickstyle=bottom, Dx=0.1, Dy=0.5, labelFontSize=\scriptstyle]{-}(0,0)(1.005,3.005)
\psBetaDist[linecolor=DarkGoldenrod1, alpha=1, beta=1]{0.005}{0.995}
\psBetaDist[linecolor=OliveDrab4, alpha=7, beta=5]{0.005}{0.995}
\end{pspicture*}
\end{document}