Your Ad Here

Posted By

f on 01/16/09


Tagged

siteDependent


Versions (?)

統一發票中獎號碼單


 / Published in: JavaScript
 

URL: http://invoice.etax.nat.gov.tw/etaxinfo_1.htm

計算該期期望值。

特獎一組

  • 1 / 10^8 * 200000
  • ans = 0.002

頭獎一組

  • a = [200000 40000 10000 4000 1000 200]';
  • xa = [10^0 10^1 10^2 10^3 10^4 10^5];
  • xb = [0 10^0 10^1 10^2 10^3 10^4];
  • x = xa - xb;
  • y = 10^8;
  • x / y * a
  • ans = 0.32060

增開六獎一組

  • 10^5 / 10^8 * 200
  • ans = 0.2

  1. /*
  2. javascript: var ax = 0; var bx = [0.002, 0.3206, 0.2]; var cx, th = document.getElementsByTagName("th"); var dx = new Array(); for (cx = 0; cx < th.length; cx++) switch (th[cx].textContent) { case "特獎": dx.push( th[cx].nextSibling.textContent.split("、") ); break; case "頭獎": dx.push( th[cx].nextSibling.textContent.split("、") ); break; case "增開六獎": dx.push( th[cx].nextSibling.textContent.split("、") ); break; } for (cx = 0; cx < dx.length; cx++) ax += bx[cx] * dx[cx].length; alert(ax + " is the expected value."); undefined;
  3.  */
  4. var ax = 0;
  5. var bx = [0.002, 0.3206, 0.2];
  6. var cx, th = document.getElementsByTagName("th");
  7. var dx = new Array();
  8. for (cx = 0; cx < th.length; cx++)
  9. switch (th[cx].textContent)
  10. {
  11. case "特獎": dx.push( th[cx].nextSibling.textContent.split("、") ); break;
  12. case "頭獎": dx.push( th[cx].nextSibling.textContent.split("、") ); break;
  13. case "增開六獎": dx.push( th[cx].nextSibling.textContent.split("、") ); break;
  14. }
  15. for (cx = 0; cx < dx.length; cx++)
  16. ax += bx[cx] * dx[cx].length;
  17. alert(ax + " is the expected value.");
  18. undefined;

Report this snippet  

You need to login to post a comment.