How to resolve the algorithm Diversity prediction theorem step by step in the REXX programming language
How to resolve the algorithm Diversity prediction theorem step by step in the REXX programming language
Table of Contents
Problem Statement
The wisdom of the crowd is the collective opinion of a group of individuals rather than that of a single expert. Wisdom-of-the-crowds research routinely attributes the superiority of crowd averages over individual judgments to the elimination of individual noise, an explanation that assumes independence of the individual judgments from each other. Thus the crowd tends to make its best decisions if it is made up of diverse opinions and ideologies.
Scott E. Page introduced the diversity prediction theorem:
Therefore, when the diversity in a group is large, the error of the crowd is small.
For a given true value and a number of number of estimates (from a crowd), show (here on this page):
Use (at least) these two examples:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Diversity prediction theorem step by step in the REXX programming language
Source code in the rexx programming language
/* REXX */
Numeric Digits 20
Call diversityTheorem 49,'48 47 51'
Say '--------------------------------------'
Call diversityTheorem 49,'48 47 51 42'
Exit
diversityTheorem:
Parse Arg truth,list
average=average(list)
Say 'average-error='averageSquareDiff(truth,list)
Say 'crowd-error='||(truth-average)**2
Say 'diversity='averageSquareDiff(average,list)
Return
average: Procedure
Parse Arg list
res=0
Do i=1 To words(list)
res=res+word(list,i) /* accumulate list elements */
End
Return res/words(list) /* return the average */
averageSquareDiff: Procedure
Parse Arg a,list
res=0
Do i=1 To words(list)
x=word(list,i)
res=res+(x-a)**2 /* accumulate square of differences */
End
Return res/words(list) /* return the average */
/*REXX program calculates the average error, crowd error, and prediction diversity. */
numeric digits 50 /*use precision of fifty decimal digits*/
call diversity 49, 48 47 51 /*true value and the crowd predictions.*/
call diversity 49, 48 47 51 42 /* " " " " " " */
exit 0 /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
avg: $= 0; do j=1 for #; $= $ + word(x, j) ; end; return $ / #
avgSD: $= 0; arg y; do j=1 for #; $= $ + (word(x, j) - y)**2; end; return $ / #
/*──────────────────────────────────────────────────────────────────────────────────────*/
diversity: parse arg true, x; #= words(x); a= avg() /*get args; count #est; avg*/
say ' the true value: ' true copies("═", 20) "crowd estimates: " x
say ' the average error: ' format( avgSD(true) , , 6) / 1
say ' the crowd error: ' format( (true-a) **2, , 6) / 1
say 'prediction diversity: ' format( avgSD(a) , , 6) / 1; say; say
return /* └─── show 6 dec. digs.*/
You may also check:How to resolve the algorithm Perfect numbers step by step in the Logo programming language
You may also check:How to resolve the algorithm Five weekends step by step in the Pascal programming language
You may also check:How to resolve the algorithm 100 doors step by step in the mIRC Scripting Language programming language
You may also check:How to resolve the algorithm 99 bottles of beer step by step in the Arbre programming language
You may also check:How to resolve the algorithm Bitcoin/address validation step by step in the PHP programming language