값을 나타내는 점선으로 브라운 운동 플로팅

값을 나타내는 점선으로 브라운 운동 플로팅

LaTeX에서 (TikZ 또는 다른 것을 통해) 아래 그림과 유사한 플롯을 만들고 싶습니다. 나는 이미 브라운 경로를 그리는 방법을 찾았습니다. 그런데 아래 그림에 표시된 점선을 추가하는 방법을 모르겠습니다. 이 선은 브라운 경로가 특정 값에 도달할 때 만들어지며 레이블은 숫자가 아닌 문자가 됩니다. 감사합니다!

예

실제로 제가 찾은 브라운 경로를 그리는 방법은 다음과 같습니다. tikz/pgf에서 브라운 운동을 그리는 방법

해당 링크의 답변에서처럼 상한 또는 하한을 추가할 필요가 없습니다. 그러나 일부 특정 값에 대해서는 점선을 추가해야 합니다.

답변1

다음은메타포스트에 싸여luamplib. 로 컴파일하고 lualatex자세한 내용을 보려면 링크를 따르세요.

여기에 이미지 설명을 입력하세요

\RequirePackage{luatex85}
\documentclass[border=5mm]{standalone}
\usepackage{luamplib}
\begin{document}
\mplibtextextlabel{enable}
\begin{mplibcode}
beginfig(1);

% set a seed, so it is repeatable (it will work fine if you 
% delete this, but you will get a different path...)
randomseed := 1288.27463;

numeric a, u, v, wt, N, hi, lo;
% parameters
a = 0;
N = 100;
lo = -hi = infinity;
wt = 2/5; % weight - larger = more random

% scales
u = 1mm; % scale
v = 1cm;

% make the brownian path, keeping track of the hi and lo points
% you could use uniformdeviate or calculate a more complicated
% distribution here instead of "normaldeviate"
path A;
A = (origin for t=1 upto N: 
        hide( 
            if a>hi: hi := a; fi if a<lo: lo := a; fi 
            a := a + wt * normaldeviate; 
        )
        -- (t,a) 
     endfor) xscaled u yscaled v;

% draw in the axes nicely
drawoptions(withcolor 1/2 white);
draw ((0,lo)--(0,hi)) scaled v;
for i=ceiling(lo) upto floor(hi) : 
    draw (left--right) scaled 2 shifted (0,i*v);
    label.lft("$" & decimal i & "$", (0,i*v)); 
endfor
draw (origin--right) scaled (N*u);

% draw the markers at the desired points along the brownian motion path
drawoptions(dashed evenly scaled 1/2 withcolor 2/3 blue);

z0 = point 44 of A; 
draw (x0,-16) -- z0 -- (-16,y0); 
label.bot("$T_0$", (x0,-16));
label.lft("$M_0$", (-16,y0));

z1 = point 81 of A; 
draw (x1,-16) -- z1 -- (-16,y1); 
label.bot("$T_1$", (x1,-16));
label.lft("$M_1$", (-16,y1));

% etc...

% finally draw the path on top of everything else
drawoptions(withcolor 2/3 red);
draw A;

drawoptions();
endfig;
\end{mplibcode}
\end{document}

관련 정보