Save by clicking here (with the right mouse button) the file on your computer (change the name if you want, but leave ".htm").
At this point you can use it to calculate any probability.
Just open the source code, edit TruthValue, and run "save".  You can repeat this several times.

First example  (incorporated in the initial version of the script)
In a dice game players throw three dice; who first gets at least 2 equal numbers wins. What is the probability of getting this in a throw?

```function TruthValue()
{ with(Math) {
/// the current event is: I throw three dice.
/// What is the probability of getting at least 2 equal numbers?

///--------

U1 = floor(random()*6+1);
U2 = floor(random()*6+1);
U3 = floor(random()*6+1);
V=0;
if (U1==U2) { V = 1};
if (U1==U3) { V = 1};
if (U2==U3) { V = 1};

///--------
}}

I have (with "n+": 10000, 10000, 20000, 40000, ...):
n=10240000 44.443642578125% +/- 0.046584667751577526%
n=5120000 44.41736328125% +/- 0.06587676682454288%
n=2560000 44.437421875% +/- 0.09316804416641197%
n=1280000 44.4278125%  +/- 0.13175668240289726%
n=640000 44.41859375% +/- 0.18632827992836345%
n=320000 44.4684375% +/- 0.2635377451554643%
n=160000 44.32375%  +/- 0.37257684179693506%
n=80000 44.25125% +/- 0.5268164338326546%
n=40000 44.0025% +/- 0.7445942580419068%
n=20000 44.125% +/- 1.0533391879742468%
n=10000 44.23% +/- 1.4900531587301118%```

I get an estimate of the probability, which can help me to check the possible solution found theoretically (in this case I know how to find it:
it is  0.444 ... = 1−5/6*4/6 = 4/9.  Why?).

[I reflect. The probability that the 2nd output is different from the first one is 5/6. The probablity that the third output is different from the first two is 4/6. The probablity that the 3 outputs are different is 5/6*4/6. So the probability that at least 2 are equal is:  1−5/6*4/6 = 4/9]

Second example
In a certain population of adults in a given region, a particular childhood disease is known to affect 1 in 8 people.  If you consider 100 adult people from that region, calculate the probability that no more than 10 have been affected by it.

```function TruthValue()
{ with(Math) {

V = 0; P = 1/8; N = 100; k = 0
for(i=1; i <= N; i++) {if(random() < P) {k = k+1} }
if(k < 11) {V = 1}

}}

n=640000 28.09109375% +/- 0.16854166235983364%
n=320000 28.0340625% +/- 0.2382064168558167%
n=160000 27.92% +/- 0.336455565438695%
n=80000 28.0175% +/- 0.4763291159111611%
n=40000 27.9825% +/- 0.6733780639760818%
n=20000 27.905% +/- 0.9515041811575701%
n=10000 27.61% +/- 1.3412676876377028%
```

The probability if 28.1%.  It is demonstrable (how?) that the probability is 28.09992%.

Third example
The probability (by drawing 10 cards from a 40-pack deck) to get at least a tris (ie 3 or 4 cards of the same value).

I put in random order the first 40 positive integers in C.  I consider the numbers from 1 to 10, ..., from 31 to 40 if they were the cards of the same suit.  If C is 37 or 17 ... C%10 is 7.  I start from a low value of n.

```function TruthValue()
{ with(Math) {

var C = new Array(40); var N = new Array(10);
C=floor(random()*40+1);
for(i=2; i <= 40; i++)
{ U=0; while(U < 1) { C[i]=floor(random()*40+1); U=1; for(j=1; j < i; j++) { if(C[j]==C[i]) {U=0} } } }
V=0; for(i=1; i<=10; i++) {N[i]=0};
i=1; while(i<11) { x=1+C[i]%10; N[x]=N[x]+1; if(N[x]==3) {i=11; V=1} else {i=i+1}  }

}}

n=256000 38.399609375% +/- 0.2883747669871522%
n=128000 38.51328125% +/- 0.4080504730615265%
n=64000 38.578125% +/- 0.5772537376074992%
n=32000 39.0125% +/- 0.818041540542717%
n=16000 39.5% +/- 1.1594474524098457%
n=8000 39.575% +/- 1.6402958934906455%
n=4000 38.85% +/- 2.312273994957548%
n=2000 38.7% +/- 3.2681394351654953%
n=1000 37.4% +/- 4.592630210701952%```

It is not easy to find the exact value;  with the script you can arrive for example to 38.452% +/− 0.129%  (or, if you have time, to 38.436% +/− 0.047%).