Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question

closed as off-topic by m_goldberg, rasher, bobthechemist, belisarius, Yves Klett Apr 21 at 6:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – m_goldberg, rasher, bobthechemist, belisarius, Yves Klett
If this question can be reworded to fit the rules in the help center, please edit the question.

For your two-digit number output problem you might use Round[#., 0.01]& –  m_goldberg Apr 20 at 14:15
And an earlier one on stackoverflow: stackoverflow.com/questions/7283109/… –  Sjoerd C. de Vries Apr 20 at 19:10
@SjoerdC.deVries, thx. It works! ^_^ –  Vitaliy Sergeyevich Barash Apr 20 at 20:14
add comment

2 Answers 2

up vote 0 down vote accepted

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.

share|improve this answer
Thanks you for your attention! :) It works well! –  Vitaliy Sergeyevich Barash Apr 20 at 20:25
add comment

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.

share|improve this answer
Thx, I done it, but Manipulate still executes all twice =/ –  Vitaliy Sergeyevich Barash Apr 20 at 20:16
Only executes once on my machine. Given Sjoerd C. de Vries answer, maybe it's the speed of the machines. –  bill s Apr 20 at 21:11
add comment

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