You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
548 B

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