J[n_]:= Catch[j=0; While[2^j<n, j++]; If[2^j ==n, Throw[j],else Throw[j-1]]]

K[n_]:= n-2^(J[n])

Mwavelet[t_]:= Piecewise [{{2 t, t≥0 && t< 1/2},{2(1-t),t≥ 1/2 && t≤1}}]

Dwavelet[t_,n_]:= Mwavelet[2^(J[n])t-K[n]]
Nullwavelet[t_] := Piecewise[{{t,t≥0 && t≤1}}]

Plot[{Dwavelet[t,1],Dwavelet[t,2], Dwavelet[t,3],Dwavelet[t,4],Dwavelet[t,5],Dwavelet[t,6],Dwavelet[t,7]},{t,-0.3,1.3}, PlotStyle->{Green, Red,Red,Blue,Blue,Blue, Blue}, AxesLabel -> {"t","g_n(t)"}]

Lambda[n_]:= 1/2 2^(-J[n]/2)

Pomocna[t_]:= Sum[Lambda[k] Dwavelet[t,k],{k,1,126}]+ Nullwavelet[t]
Plot[Pomocna[t],{t,-0.3,1.3}, AxesLabel-> {"t","f(t)"}]

SeedRandom[0]
nahoda=RandomVariate[NormalDistribution[0,1],127]
Wienerproces[t_]:= Sum[Lambda[k]Dwavelet[t,k]nahoda[[k]],{k,1,126}]+Nullwavelet[t]nahoda[[127]]
Plot[Wienerproces[t],{t,-0.3,1.3}, AxesLabel -> {"t","W(t)"}]

SeedRandom[0]
nahoda=RandomVariate[NormalDistribution[0,1],1000]
Wienerproces[t_]:= Sum[Lambda[k]Dwavelet[t,k]nahoda[[k]],{k,1,999}]+Nullwavelet[t]nahoda[[1000]]
Plot[Wienerproces[t],{t,-0.3,1.3}, AxesLabel -> {"t","W(t)"}]

Principref[t_]:= Piecewise[{{Wienerproces[t],t<0.3},{2Wienerproces[0.3]-Wienerproces[t], t ≥ 0.3 && t≤1 }}]
Plot[Principref[t],{t,-0.3,1.3}]

Plot[{Wienerproces[t],Principref[t],Wienerproces[0.3]}, {t,-0.3,1.3},PlotStyle->{Blue, Red, Green}, AxesLabel->{"t","V(t)"}]