blob: a7d17e4c556b454bb7939ce64c304c5f7daf1cf2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
/*Arithmetic Mean of a large number of Integers
- or - solve a very large constraint matrix
over 1 million rows and columns
Nigel_Galloway@operamail.com
March 18th., 2008.
*/
param e := 20;
/* set Sample := {-2**e..2**e-1}; */
set Sample := {1..2**e-1};
var Mean;
var E{z in Sample};
/* sum of variances is zero */
zumVariance: sum{z in Sample} E[z] = 0;
/* Mean + variance[n] = Sample[n] */
variances{z in Sample}: Mean + E[z] = z;
solve;
printf "The arithmetic mean of the integers from 1 to %d is %f\n", 2**e-1, Mean;
end;
|