TikZ 関数の数値が大きすぎます

TikZ 関数の数値が大きすぎます

事前分布と事後分布を比較する 2 つのベータ分布を描画したいのですが、係数が LaTeX には大きすぎるようです。関数を変更せずにこれを修正するにはどうすればよいでしょうか。 や など、いくつかのエラーがありDimension too largeますNumber too big

\documentclass[10pt]{article}  
\usepackage{pgf,tikz}  
\usetikzlibrary{arrows}  
\pagestyle{empty}  
\begin{document}  
\definecolor{qqccqq}{rgb}{0,0.8,0}  
\definecolor{qqttcc}{rgb}{0,0.2,0.8}  
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=8.333333333333332cm,y=1.0cm]  
\draw[->,color=black] (-0.1,0) -- (1.1,0);  
\foreach \x in {,0.2,0.4,0.6,0.8,1}  
\draw[shift={(\x,0)},color=black] (0pt,2pt) -- (0pt,-2pt) node[below] {\footnotesize $\x$};  
\draw[color=black] (1.04,0.04) node [anchor=south west] { $\theta$};  
\draw[->,color=black] (0,-0.5) -- (0,5.5);    
\foreach \y in {,1,2,3,4,5}    
\draw[shift={(0,\y)},color=black] (2pt,0pt) -- (-2pt,0pt) node[left] {\footnotesize $\y$};  
\draw[color=black] (0pt,-10pt) node[right] {\footnotesize $0$};  
\clip(-0.1,-0.5) rectangle (1.1,5.5);  
\draw[dash pattern=on 1pt off 1pt,color=qqttcc, smooth,samples=100,domain=8.000000000003847E-7:0.9999990727280006] plot(\x,{3682570000*(1-(\x))^(10.67)*(\x)^(21.49)});  
\draw[color=qqccqq, smooth,samples=100,domain=8.000000000003847E-7:0.9999990727280006] plot(\x,{2120.93*(1-(\x))^(2.67)*(\x)^(9.49)});  
\draw (0.49,4.17) node[anchor=north west] {$g(\theta|D)$};  
\draw (0.89,3.23) node[anchor=north west] {$g(\theta)$};  
\end{tikzpicture}  
\end{document}

答え1

Asymptote オプションも検討してください。これは、特に曲線の配列がある場合にグラフ描画に非常に強力です。以下の例では、関数を配列に整理しています。色、幅、ラベルなどの他のプロパティも配列に整理して、1 つのループで描画できます。また、yラベルの - 座標は、曲線上の点として計算されます。 asy-plot.tex

\documentclass{standalone}
\usepackage{lmodern}
\usepackage[inline]{asymptote}
\begin{document}  
\begin{asy}
import graph;
size(250,170,IgnoreAspect);
real xMin=8.000000000003847e-7;
real xMax=0.9999990727280006;
int n=100;

typedef real Func(real x);

Func[] f={
   new real(real x){return 3682570000*(1-x)^(10.67)*x^(21.49);},
   new real(real x){return 2120.93*(1-x)^2.67*x^9.49;},
};

pen dashed=linetype(new real[] {4,3}); // set up dashed pattern

pen[] curvePen={rgb(0,0.8,0)+dashed,rgb(0,0.2,0.8),};
real[] curveWidth={1.6pt,2pt};
Label[] lab={
  Label("$g(\theta\,\vert D)$",(0.6,f[0](0.6))),
  Label("$g(\theta)$",(0.9,f[1](0.9))),
};

for(int i=0;i<f.length;++i){
  draw(graph(f[i], xMin ,xMax ,n),curvePen[i]+curveWidth[i]);
  label(lab[i],UnFill(2pt));
}

xaxis("",0,1.049,RightTicks(Step=0.1,step=0.05),EndArrow);
yaxis("",0,5-0.15,LeftTicks(Step=1,step=0.5),EndArrow);
\end{asy}
\end{document}

で処理するにはlatexmk、ファイルを作成しますlatexmkrc:

sub asy {return system("asy '$_[0]'");}
add_cus_dep("asy","eps",0,"asy");
add_cus_dep("asy","pdf",0,"asy");
add_cus_dep("asy","tex",0,"asy");

を実行しますlatexmk -pdf asy-plot.tex。結果は次のようになります。

ここに画像の説明を入力してください

答え2

直接的な答えではありませんが、私はpgfplotsこれに使用します。fpu適切な時点でライブラリをオンにすると問題が解決するかもしれませんが、軸などを描画する必要がないため、これがはるかに便利だと思います。

\documentclass{standalone}
\usepackage{pgfplots}
\usetikzlibrary{arrows}  
\definecolor{qqccqq}{rgb}{0,0.8,0}
\definecolor{qqttcc}{rgb}{0,0.2,0.8}
\begin{document}  
\begin{tikzpicture}[line cap=round,line join=round]
\begin{axis}[
    axis lines=middle,
    every inner x axis line/.append style={-triangle 45},
    every inner y axis line/.append style={-triangle 45},
    enlargelimits]
\addplot[dash pattern=on 1pt off 1pt,color=qqttcc, smooth,samples=100,domain=8.000000000003847E-7:0.9999990727280006] plot(\x,{3682570000*(1-(\x))^(10.67)*(\x)^(21.49)});  
\addplot[color=qqccqq, smooth,samples=100,domain=8.000000000003847E-7:0.9999990727280006] plot(\x,{2120.93*(1-(\x))^(2.67)*(\x)^(9.49)});  
\node at (axis cs:0.49,4.17) {$g(\theta|D)$};  
\node at (axis cs:0.89,3.23) {$g(\theta)$};  
\end{axis}
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

編集に関連する問題は、ドメインの終わりに向かって数字が小さくなりすぎることです。y軸を対数軸に切り替えたことを示すために。TeXはその精度を処理できませんが、fpuTikZのライブラリまたはpgfplotsデフォルトではある程度まで処理でき、ゼロ除算エラーで終了します。それ以外の場合は、 TeXの外部でディレクティブを実行pgfplotsできますgnuplot。のマニュアルを確認してくださいpgfplots。また、使用するすべての色を定義する必要はありません。xcolorは非常に強力なパッケージであるため、色の混合機能を使用できます。軸設定などがない最小限の例を次に示します。使いやすさを示します。

\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.8} % The latest version on CTAN
\begin{document}  
\begin{tikzpicture}
\begin{semilogyaxis}
\addplot[red,smooth,samples=100,domain=0.0:1.0] {(3.1415926535*sin(((x)*3.1415926535)*180/pi))/2};  
\addplot[green!80!black, smooth,samples=100,domain=0.0:1.0] {(x)^1^2*(1-(x))^8*sin(((x)*3.1415926535)*180/pi)*1/(3.44*10^(-7))};  
\addplot[blue!80!green, ultra thick,smooth,samples=100,domain=0.0:1.0] {2.718281828^((-((x)-0.58)^2)/(0.1^2*2))/(abs(0.1)*sqrt(3.1415926535*2))};
\end{semilogyaxis}
\end{tikzpicture}
\end{document}

ここに画像の説明を入力してください

関連情報