I need help, guys! Here the script:

numberProcesses = 24;
numberLevels = 4;
 numberExperts = E;
 processMatrix = 
  Table[RandomReal[{0, 1}, WorkingPrecision -> 2], {i, E}, {j, 
 aggregatedMark = 
  Table[Total[processMatrix[[All, k]]]/E, {k, numberLevels}];
 deviation = 
     Sum[RootApproximant[(processMatrix[[h, g]] - 
           aggregatedMark[[g]])^2], {h, E}]/E], 2], {g, numberLevels}];
 variation = 
    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}]];
   Table[N[Sum[processMatrix[[i, j]]*k[[t, i]], {i, E}], 2], {j, 
    Sum[Sum[groupMark[[t, i]]*processMatrix[[j, i]], {j, E}], {i, 
  temp = Table[
      Sum[(processMatrix[[i, j]]*groupMark[[t, j]]), {j, 
        numberLevels}], 2], {i, E - 1}];
    N[RootApproximant[1 - Sum[temp[[i]], {i, E - 1}]], 2]]];
  If[t >= tmax, 
       Abs[groupMark[[t, i]] - groupMark[[t - 1, i]]], {i, 
        numberLevels}]] <= 0.0001, Break[], t++], t++]];
 viewTable = Text[Grid[Append[Append[Append[Append[Append[
          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:

The result

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.


Manipulate executes all twice. It was solved - Stackoverflow. Thanks, @SjoerdC.deVries.


2 Answers 2


From my StackOverflow answer on a similar question of three years ago:

This can be solved by adding the option PerformanceGoal -> "Quality" to the Plot function.

During the display of manipulated items a lower fidelity sample of the object can be shown depending on the PerformanceGoal setting. A higher fidelity version is drawn at the end of the manipulation, if necessary. It is this later redrawing which seems to be causing the problem here.

  • $\begingroup$ Thanks you for your attention! :) It works well! $\endgroup$ Apr 20, 2014 at 20:25
  • $\begingroup$ I figure a correct, accepted answer deserves at least one upvote, even on a duplicate, as sign that someone else agrees with it, per the SE model. (Just happened to run across it this morning. April is my busiest time of the year, in general) $\endgroup$
    – Michael E2
    Feb 1, 2015 at 13:04
  • $\begingroup$ @MichaelE2 thanks, much tidier this way :) $\endgroup$ Feb 1, 2015 at 16:28

You know how people on this site are always talking about not using capital letters as symbols because it might cause problems? Well... E is the symbol for the exponential constant (2.718...). The first time through, the Manipulate evaluates everything as if E were Exp[1], then it goes through again and evaluates E as the variable in your Manipulate, i.e., {E, 3, "Number"}. So just change all the occurrences of E to e (or something else) and the multiple evaluation problem vanishes.

  • $\begingroup$ Thx, I done it, but Manipulate still executes all twice =/ $\endgroup$ Apr 20, 2014 at 20:16
  • $\begingroup$ Only executes once on my machine. Given Sjoerd C. de Vries answer, maybe it's the speed of the machines. $\endgroup$
    – bill s
    Apr 20, 2014 at 21:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.