I just want to plot all stochastic processes and their average process. The original code without the average is:
Manipulate[SeedRandom[seed];
test2[μ_, σ_, S_, P_] :=
Table[RandomFunction[
GeometricBrownianMotionProcess[μ, σ, S], {0, 250, 0.05}]["Path"], {P}];
ListLogPlot[test2[μ, σ, S, P], Joined -> True,
AxesLabel -> {"Time", "St"},
PlotLabel -> Style["Forecasted Stock Price\n (Brownian Motion)", Bold],
PlotRange -> {{0, 250}, {0, 3000}}, ImageSize -> 500,
PlotStyle -> Directive[{Thin, Lighter@Gray}]],
{{S, 100, "Initial Stock Value"}, 100, 500, 0.05, Appearance -> "Labeled"},
{{μ, 0.01, "Drift μ"}, 0.01, 1, 0.05, Appearance -> "Labeled"},
{{σ, 0.01, "Standard Deviation σ"}, 0.01, 1, 0.05, Appearance -> "Labeled"},
{{P, 1, "Paths"}, 1, 100, 1, Appearance -> "Labeled"},
{{seed, 77777, "New Random Case"}, 10000, 999999, 1},
Button["Set Initial Values", {S = 100, μ = 0.01, σ = 0.01},
ImageSize -> 150],
ControlPlacement -> Left]
So far I have done the following (changed the original gode a Little bit) but it’s not working properly since I only get the mean of all processes and not both, the processes (in grey colour) and their average process (in red colour).
Manipulate[SeedRandom[seed];
test2[μ_, σ_, S_, P_] :=
Table[RandomFunction[
GeometricBrownianMotionProcess[μ, σ, S], {0, 250, 0.05}]["Path"], {P}];
meanPaths=Mean[test2[μ,σ,S,P][[All]]];
ListLogPlot[{test2[μ, σ, S, P],meanPaths}, Joined -> True,
AxesLabel -> {"Time", "St"},
PlotLabel -> Style["Forecasted Stock Price\n (Brownian Motion)", Bold],
PlotRange -> {{0, 250}, {0, 3000}}, ImageSize -> 500,
PlotStyle -> Directive[{{Thin,Lighter@Gray},{Thickness[Medium],Red}}]],
{{S, 100, "Initial Stock Value"}, 100, 500, 0.05, Appearance -> "Labeled"},
{{μ, 0.01, "Drift μ"}, 0.01, 1, 0.05, Appearance -> "Labeled"},
{{σ, 0.01, "Standard Deviation σ"}, 0.01, 1, 0.05, Appearance -> "Labeled"},
{{P, 1, "Paths"}, 1, 100, 1, Appearance -> "Labeled"},
{{seed, 77777, "New Random Case"}, 10000, 999999, 1},
Button["Set Initial Values", {S = 100, μ = 0.01, σ = 0.01},
ImageSize -> 150],
ControlPlacement -> Left]
Any ideas what I could be missing?
Thank you for your help