Numbers

class Numbers(inThing, col=0, skip=0)[source]

Simple 1-dimensional data handling. Emphasis on ‘simple’.

Feed this a list of floats, or the name of a file containing floats. If it is a file, lines are read in only if the first character is a digit. So lines starting with words, ‘#’, or blank lines, are ignored (and those ignored lines do not contribute to the ‘skip’, below). So this should be able to read in MrBayes *.p files, sensibly skipping the first lines.

Options:

col

If inThing is a file, it can have multiple columns. This says which one to use. Zero-based!

skip

If inThing is a file, you can skip lines at the beginning. This says how many. It skips ‘skip’ data lines in addition to ignored lines, ‘cuz ignored lines are skipped anyway.

The histo() method does a simple 1-D histogram, putting the data into bins. It would be usual to not supply a binSize, in which case a suitable binSize is chosen for you. But if you don’t like the result, you can optionally specify a binSize, (eg myNumbers.binSize=10.0)

If your numbers are in more than one list or file, you can read in more stuff with the read() method.

arithmeticMeanOfLogs()[source]
property binSize

(property) Return the bin size

dump()[source]
gsl_meanVariance()[source]

Uses gsl. Returns a tuple of the mean and the variance.

harmonicMeanOfLogs()[source]

Returns log of the harmonic mean of logs.

Self is in log form. The harmonic mean is calculated after exponentiating, and the result is returned as a log.

The method was stolen uncritically from MrBayes. This gives the same result as MrBayes.

histo(verbose=True, binSize=None, padMin=None, padMax=None)[source]

Put the data nicely into bins.

After you do this, the bins are available in self.bins, a list of pairs.

Args padMin and padMax extend the range up or down, where the extended bins would have zero content, so they would be placeholders. It would be good for making two different histos have exactly the same range, eg so you can plot them in the same plot.

mean()[source]
plot(term='qt', output=None)[source]

A horrible hack to plot stuff with GnuPlot.

A file, gnuplot_instructs, is written. Then gnuplot is called. The default terminal type is ‘qt’, so that is needed.

Couldn’t this be done in a clever way with (existing) proper python hooks into GnuPlot? -yes, but it would require installing another module.

To make a png, you could call it with:

term='png', output='myPlot.png'

To plot to the terminal, say term=’dumb’.

read(inThing, col=0, skip=0)[source]

Slurp in some more numbers.

You can use this repeatedly, eg if your numbers are in more than one list or file.

tailAreaProbability(theStat, verbose=1)[source]

Access to p4.func.tailAreaProbability()

Supply theStat, ie the test quantity, and it uses self.data to make the distribution.