I have found the following clever code Brownion Motion here to plot a brownian motion:
\documentclass[border=5mm]{standalone}
\usepackage{pgfplots, pgfplotstable}
% Create a function for generating inverse normally distributed numbers using the Box–Muller transform
\pgfmathdeclarefunction{invgauss}{2}{%
\pgfmathparse{sqrt(-2ln(#1))cos(deg(2pi#2))}%
}
% Code for brownian motion
\makeatletter
\pgfplotsset{
table/.cd,
brownian motion/.style={
create on use/brown/.style={
create col/expr accum={
(\coordindex>0)(
max(
min(
invgauss(rnd,rnd)0.1+\pgfmathaccuma,
\pgfplots@brownian@max
),
\pgfplots@brownian@min
)
) + (\coordindex<1)*\pgfplots@brownian@start
}{\pgfplots@brownian@start}
},
y=brown, x expr={\coordindex},
brownian motion/.cd,
#1,
/.cd
},
brownian motion/.cd,
min/.store in=\pgfplots@brownian@min,
min=-inf,
max/.store in=\pgfplots@brownian@max,
max=inf,
start/.store in=\pgfplots@brownian@start,
start=0
}
\makeatother
%
% Initialise an empty table with a certain number of rows
\pgfplotstablenew{201}\loadedtable % How many steps?
\begin{document}
\pgfplotsset{
no markers,
xmin=0,
enlarge x limits=false,
scaled y ticks=false,
ymin=-1, ymax=1
}
\tikzset{line join=bevel}
\pgfmathsetseed{3}
\begin{tikzpicture}
\begin{axis}
\addplot table [brownian motion] {\loadedtable};
\addplot table [brownian motion] {\loadedtable};
\end{axis}
\end{tikzpicture}
\end{document}
But i'm not good enough in LaTeX/pgfplot/Tikz to understand how and where i have to change it to get a Brownian bridge instead that brownian motion.
Thanks for your help

B(t)is Brownian motion fort\in [0,1], thenBB(t)=B(t)-t*B(1)forms a Brownian Bridge on that interval. Usually, one is interested in standardized Brownian motion, i.e., a Wiener process, for whichW(1)\sim N(0,1). To generate sample paths of a Wiener process, start by normalizing the x-axis values to range from 0 to 1 instead of from 0 to n and by standardizing the variance of the increments so thatVar(B(1))=1. (You may setB(0)=0.) – Mico Jul 22 '23 at 21:16