I have the following code where I create instances of random graphs and use their properties to compute the mean of a quantity labeled 'PoA'. In the last line, I use a range of values for the parameters 'nodes' and 'conn', and create a table for plotting the mean.
I now want to bring Standard deviation also into consideration. I would like the plots to have lines for mean and mean$\pm 2 \sigma$. Can someone help me to add those extra lines in the plot?
PoAGen[nodes_, conn_, n_: 1000] :=
Module[{an = 100, al = 1, s, M, id, od, wd, x, poa, PoA},
Cases[_?NumericQ]@
Table[s =
DirectedGraph[RandomGraph[{nodes, IntegerPart[conn*nodes]}],
"Acyclic"];
M = al*Transpose[AdjacencyMatrix[s]];
id = an + al*VertexInDegree[s];
od = al*VertexOutDegree[s];
wd = -Log[1 - (od/id)];
x = (DiagonalMatrix[id] - M).wd;
poa = N[od - x, 4];
PoA = Total@poa, {n}] // Mean]
dataPlot = Table[{nodes, conn, PoAGen[nodes, conn]}, {nodes, 20, 40, 2},
{conn,2.5, 5, 0.2}];
ListPlot[dataPlot[[All, 1, {1, 3}]], Frame -> True, Joined -> True,
FrameLabel -> {"|V|", "Inefficiency \[CapitalDelta]"},
PlotLabel -> "|E|/|V|=: " ~~ ToString[dataPlot[[1, 1, 2]]]]
ListPlot[dataPlot[[2, All, {2, 3}]], Frame -> True, Joined -> True,
FrameLabel -> {"|E|/|V|", "Inefficiency \[CapitalDelta]"},
PlotLabel -> "|V|: " ~~ ToString[dataPlot[[1, 1, 1]]]]
Mean
andStandardDeviation
and return those as a list. You will get a slightly more complex expression fordataPlot
, but it should be relatively simple to extract the data you need and plot it, just like you extract the means. $\endgroup$