[Tutor] What's the best way to model an unfair coin?

Steven D'Aprano steve at pearwood.info
Sun Oct 24 14:43:30 CEST 2010

Evert Rol wrote:

> Btw, to be pedantic, 1/e is not an irrational number, just a real number. i/e would be.

Actually, Richard is correct. Like π, e and 1/e are irrational numbers. 
"Irrational" means the number is not rational, in the sense of *ratio*, 
not sanity :)

There is no exact ratio of integers which give *exactly* π, e, 1/e, or 
many other numbers, although you can get as close an approximation as 
you like. Hence they are known as irrationals. Many surds, like square 
root of 2, are irrational. Not all of them though: sqrt(4) is rational.

Mathematicians deal with a hierarchy of numbers:

Natural numbers: 1, 2, 3, 4, ...
Integers: 0, 1, -1, 2, -2, 3, -3, ...
Rationals: numbers that can be written as ratios of two integers, e.g. 
1/2, 3/7, ...
Irrationals: numbers that can't be written as such ratios.

The rationals and the irrationals together make up the real numbers. 
"Real" in the sense that when you measure real quantities like distance 
or weight, you get a real number.

The number system has been extended to "imaginary" numbers, complex 
numbers, quaternions, surreal numbers, and other more exotic families. 
Python includes support for complex numbers, using "j" as the symbol for 
the imaginary unit:

 >>> 2 + 3j  # real number + imaginary number makes a complex number

(Mathematicians will be more familiar with the symbol i, but electrical 
engineers usually use j.)


More information about the Tutor mailing list