
ベイズの法則 (または特定の関数) で定義された数値にノードが配置されるように、[0,1] に数直線を描画します。つまり、初期値 x' (私が指定) に対して、プログラムが後続のすべてのノード x にノードを配置するようにします。ここで、x= x'/((1+x')*0.5) となり、最大 x が 1 になるまでこれを続けます。これは、別の同様の投稿から私が考案した MWE です。
\begin{tikzpicture}
\begin{axis}[
axis x line=middle,
axis y line=none,
width=\textwidth,
xmin=0,xmax=1,
xtick={0,1},
xticklabels={$0$,$1$},
xlabel=$\beta$
]
\addplot[samples at={1,...,100},only marks,mark size=0.5,blue] (x/((1+x)*0.5),0);
\end{axis}
\end{tikzpicture}
ここで、サンプルを使用して実行するのではなく、初期値 (指定可能) で実行し、x が 1 に達するまで他の数値まで徐々に増やしていきたいと思います。
さらに、これらのノードを識別して、これらの数字の間に曲線の矢印を描いてジャンプを示すことができるようにします。
複数のアプローチを試しましたが、初期値を持つ式に従って、TikZ でそのようなシーケンスの特定の数値をプロットすることに成功しませんでした。もちろん、すべてを個別に簡単に解決してからプロットすることもできますが、この醜いブルート フォース メソッドは使用したくありません。
ご協力いただければ幸いです。よろしくお願いします :)
答え1
これはあなたが望んでいるものに近いと思います。初期値はステートメントでポイント単位で設定されます\setlength
。値が 1 に達することはないので、while ループで 0.99pt を使用しました。
コードには多くのコメントがありますので、不明な点があれば質問してください。また、誤解している場合はお知らせください。
\documentclass{article}
\usepackage{tikz}
\usepackage{ifthen} % for whiledo
% set initial value
\newlength\MyX
\setlength\MyX{0.1pt}
% counter for giving a different name to each node
\newcounter{XCnt}
\setcounter{XCnt}{1}
% for convenience
\newcommand\XScale{200}
\newcommand\XMax{1}
\begin{document}
Diagram using the values set up in preamble:
\begin{center}
\begin{tikzpicture}
\draw[gray, very thin,|-stealth] (0,0) node[below] {$0$} -- (\XMax*\XScale pt,0) node[below] {$\XMax$};
% basic while loop
\whiledo{\lengthtest{\MyX<0.99pt}}{%
%draw filled node at x-position given by the \MyX length
\node [inner sep=0pt,minimum size=2pt,fill,circle] (n-\theXCnt) at (\MyX*\XScale,0) {};
% calculate new length
\pgfmathsetlengthmacro{\MyX}{\MyX/((1+\MyX)*0.5)}
% add 1 to the naming counter
\stepcounter{XCnt}
% to see the values of \MyX in the log, not necessary
\typeout{\MyX}
}
% one example to show that the nodes can be referenced
\draw [red,latex-latex] (n-1) to[bend left] (n-4);
\end{tikzpicture}
\end{center}
Then a second diagram, with slightly different equation, different initial value and scale:
\begin{center}
% set different initial value
\setlength\MyX{0.02pt}
% reset node naming counter
\setcounter{XCnt}{1}
% change scale, if necessary
\renewcommand\XScale{50}
\renewcommand\XMax{4}
\begin{tikzpicture}
\draw[gray, very thin,-stealth] (0,0) -- (\XMax*\XScale pt+3mm,0); % +3mm to extend the line a bit
% draw tick marks:
\foreach \x in {0,...,\XMax}
\draw [gray,very thin] (\x*\XScale pt,3pt) -- +(0,-6pt) node[below]{$\x$};
\whiledo{\lengthtest{\MyX<3.999pt}}{% note changed limit
\node [inner sep=0pt,minimum size=2pt,fill,circle] (n-\theXCnt) at (\MyX*\XScale,0) {};
\pgfmathsetlengthmacro{\MyX}{\MyX/((1+\MyX)*0.2)}
\stepcounter{XCnt}
\typeout{\MyX}
}
% one example to show that the nodes can be referenced
\draw [red,latex-latex] (n-1) to[bend left] (n-4);
\end{tikzpicture}
\end{center}
\end{document}