Diversity prediction theorem: Difference between revisions

Added XPL0 example.
m (syntax highlighting fixup automation)
(Added XPL0 example.)
Line 1,756:
Crowd-error : 4.000
Diversity : 10.500
</pre>
 
=={{header|XPL0}}==
<syntaxhighlight lang "XPL0">real Estimates, TrueVal, AvgErr, CrowdErr, Sum, Avg;
int I, J;
[Estimates:= [ [48., 47., 51., 0.], [48., 47., 51., 42., 0.] ];
TrueVal:= 49.;
Format(2, 3);
for I:= 0 to 1 do
[Sum:= 0.; J:= 0;
while Estimates(I,J) # 0. do
[Sum:= Sum + sq(Estimates(I,J) - TrueVal); J:= J+1];
AvgErr:= Sum/float(J);
Text(0, "Average error : "); RlOut(0, AvgErr); CrLf(0);
 
Sum:= 0.; J:= 0;
while Estimates(I,J) # 0. do
[Sum:= Sum + Estimates(I,J); J:= J+1];
Avg:= Sum/float(J);
CrowdErr:= sq(TrueVal-Avg);
Text(0, "Crowd error : "); RlOut(0, CrowdErr); CrLf(0);
 
Text(0, "Diversity : ");
RlOut(0, AvgErr - CrowdErr); CrLf(0);
CrLf(0);
];
]</syntaxhighlight>
{{out}}
<pre>
Average error : 3.000
Crowd error : 0.111
Diversity : 2.889
 
Average error : 14.500
Crowd error : 4.000
Diversity : 10.500
 
</pre>
 
295

edits