BinaryStrings
PyCellChemistry documentation index
/Users/lidia/main/research/acbook/web/website/ac-home/pycellchem/pycellchem-2.0/src/artchem/BinaryStrings.py

#---------------------------------------------------------------------------
#
# BinaryStrings.py: a module to manipulate binary strings as integers
#
# by Lidia Yamamoto, Belgium, July 2013
#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
# Copyright (C) 2015 Lidia A. R. Yamamoto
# Contact: http://www.artificial-chemistries.org/
#
# This file is part of PyCellChemistry.
#
# PyCellChemistry is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# version 3, as published by the Free Software Foundation.
#
# PyCellChemistry is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PyCellChemistry, see file COPYING. If not, see
# http://www.gnu.org/licenses/
#


Modules
numpy
sys
time


Functions
count_ones(binstr)
number of ones in a binary string
crossover(s1, s2, nbits)
crossover between two binary strings s1 and s2 at a random position;
returns two children c1 and c2
dice(prob)
throw a dice: true if the dice falls within the given probability
entropy(binstr, nbits)
entropy of a binary string
CAUTION: for a string of nbits, there are only nbits/2 + 1
different entropy levels 0 <= entropy <= 1 including 0.0
(for p0 = 0 or p0 = 1) and 1.0 (for p0=p1=0.5)
flipbit(binstr, pos, nbits)
flip a given bit in the string
getbitvalue(binstr, pos)
get value of the bit at position 'pos' in binary string 'binstr'
getsegment(binstr, p0, p1)
get value of segment from p0 to p1 in binary string 'binstr'
hamming(x, y)
Hamming distance between two integers x and y
int2str(binstr, nbits)
converts an integer to a string containing the binary number
in ascii form, without prefix '0b' and filled with leading
zeros up to nbits
mutate1(binstr, nbits)
mutate a random bit in the string
mutatep(binstr, nbits, prob)
mutate each bit in the string with a given probability
caution: this method is computationally much slower than mutate1()
randbin(nbits, p1=0.5)
random integer with a given number of bits 'nbits'
bits are uniformly distributed, with a possible bias:
p1 = probability of a one
p0 = 1 - p1 = probability of a 0
randprob()
random floating point number between 0 and 1


Generated automatically by pydoc, July 10, 2015