I need help, guys! Here the script:
numberProcesses = 24;
numberLevels = 4;
Manipulate[
numberExperts = E;
processMatrix =
Table[RandomReal[{0, 1}, WorkingPrecision -> 2], {i, E}, {j,
numberLevels}];
aggregatedMark =
Table[Total[processMatrix[[All, k]]]/E, {k, numberLevels}];
deviation =
Table[N[Sqrt[
Sum[RootApproximant[(processMatrix[[h, g]] -
aggregatedMark[[g]])^2], {h, E}]/E], 2], {g, numberLevels}];
variation =
Table[N[RootApproximant[deviation[[g]]/aggregatedMark[[g]]*100],
2], {g, numberLevels}];
graphTable =
Table[Show[{Histogram[processMatrix[[All, j]], {0, 1, 0.1}, "PDF"],
SmoothHistogram[processMatrix[[All, j]],
PlotStyle -> Thick]}], {j, numberLevels}];
groupMark = {};
k = {};
l = {};
tmax = 2;
t = 1;
AppendTo[k, Table[1/E, {i, E}]];
While[True,
AppendTo[groupMark,
Table[N[Sum[processMatrix[[i, j]]*k[[t, i]], {i, E}], 2], {j,
numberLevels}]];
AppendTo[l,
RootApproximant[
Sum[Sum[groupMark[[t, i]]*processMatrix[[j, i]], {j, E}], {i,
numberLevels}]]];
temp = Table[
N[1/l[[t]]*
Sum[(processMatrix[[i, j]]*groupMark[[t, j]]), {j,
numberLevels}], 2], {i, E - 1}];
AppendTo[k,
AppendTo[temp,
N[RootApproximant[1 - Sum[temp[[i]], {i, E - 1}]], 2]]];
If[t >= tmax,
If[Max[Table[
Abs[groupMark[[t, i]] - groupMark[[t - 1, i]]], {i,
numberLevels}]] <= 0.0001, Break[], t++], t++]];
viewTable = Text[Grid[Append[Append[Append[Append[Append[
MapThread[
Prepend, {Prepend[
processMatrix, {"Второй уровень", "Третий уровень",
"Четвёртый уровень", "Пятый уровень"}],
Prepend[Table[i, {i, E}], ""]}],
Insert[aggregatedMark, "fi",1]],
Insert[deviation, "Sigma", 1]],
Insert[variation, "V", 1]],
Insert[graphTable, "Graph", 1]],
Insert[groupMark[[t, All]], "Mark", 1]], Frame -> All,
Background -> LightYellow]], {{E, 3, "Number"}, 2,
100, 1}, ContinuousAction -> False, TrackedSymbols -> {E}]
It does:
And most of that works well, but when the E
value is changed Manipulate
executes all twice... Why is it so? I really don't understand. I tried delete the graphs from the table. After that I saw Manipulate
didn't execute all twice. It's magic =/
Secondly, I don't know how I can get real numbers with only two digits after the point (0.xx). When I use N[,2]
Mathematica returns sometimes 0.0xx or 0.00xx. But I wanna get 0.0x or 0.00 (of course, using the standard rule for rounding). How can I do it?
And last but not least, as you can see I used such functions as RootApproximant
. I don't want use it, but sometimes without 'em Mathematica says: No significant digits are available to display
. What can I do?
I will be happy if someone will help me optimize the script. Thank you for your attention.
EDITED
Manipulate
executes all twice. It was solved - Stackoverflow. Thanks, @SjoerdC.deVries.
Round[#., 0.01]&
$\endgroup$