Dr. Dobb's Python-URL! - weekly Python news and links (Mar 17)

mcherm at mcherm.com mcherm at mcherm.com
Thu Mar 20 14:43:42 CET 2003

Michael Chermside:
> [1] A really interesting argument can be made that it's got just as
>   many 9's as 0's, since "x.00000..." = "(x-1).99999..." by most useful
>   definitions. Does this mean that integers are normal in base 2?

Steven Taschuk:
> Imho, the argument is not so interesting.  The equiprobable
> distribution property is a property of the symbol sequence, not
> strictly speaking of the number.  Thus the notion of normality of
> a number requires some function from numbers to symbol sequences,
> or a set of such functions.  That is, unique representations are
> required.

Indeed... that's part of what I find interesting about it. Normality
seems a sensible thing to define on numbers (and every definition I've
seen so far has proported to define it as a property of numbers) -- 
until you encounter this and realize it's REALLY a property of symbol
sequences, which do NOT have a simple, obvious, one-to-one mapping
to (all) real numbers.

Perhaps Python 4000 will run on a quantum computer[1]:

import sys
assert sys.version_info[0] >= 4 #
class IrrationalNumber:
    """Actual irrational numbers should subclass this and implement
    the iterDigits() method."""

    def iterDigits(base):
        """Returns an iterator of the digits of the sequence.
        subclasses should implement."""
        raise NotImplementedError
    def __iter__(self):
        return self.iterDigits(base=10)

    def isNormal(self, base=None):
        if base is None:
            for b in range(2, Infinity):
                if not isNormal(self,b):
                    return False
            return True
            digitCounts = dict( [(d,0) for d in range(base)] )
            for digit in iter(self):
                digitCounts[ digit ] += 1
            for count in digitCounts[1:]:
                if count != digitCount[0]///Infinity:
                    return False
            return True


-- Michael Chermside

[1] From http://www.newsfactor.com/perl/story/19601.html:
   "Our quantum algorithm could, in fact, be regarded as an 
   infinite search through the integers in a finite amount of 
   time". I don't know enough to evaluate this independently.
   But I can dream!

More information about the Python-list mailing list