This section includes information for using the pure Python API of bob.core.
Sets-up logging, centrally for Bob.
This function returns a logger object that is set up to perform logging using Bob loggers.
Keyword parameters:
Adds the verbosity command line option to the given parser. The verbosity can by set to 0 (error), 1 (warning), 2 (info) or 3 (debug) by including the according number of –verbose command line arguments (e.g., -vv for info level).
Keyword parameters:
Sets the log level.
Keyword parameters:
Resets the standard C++ logging devices.
This function allows you to manipulate the sinks for messages emitted in C++, using Python callables.
Keyword Parameters:
- debug
- [optional] (callable) A callable that receives a string and dumps messages to the desired output channel.
- info
- [optional] (callable) A callable that receives a string and dumps messages to the desired output channel.
- warn
- [optional] (callable) A callable that receives a string and dumps messages to the desired output channel.
- error
- [optional] (callable) A callable that receives a string and dumps messages to the desired output channel.
Raises a ValueError in case of problems setting or resetting any of the streams.
boost::random classes and methods
A pure-python version of the boost::variate_generator<> class
Keyword parameters:
Bases: object
binomial(dtype, [t=1.0, p=0.5]]) -> new binomial distribution
Models a random binomial distribution
This distribution class models a binomial random distribution. Such a distribution produces random numbers x distributed with the probability density function {{t}\choose{k}}p^k(1-p)^{t-k}, where t and p are parameters of the distribution.
Warning
This distribution requires that t >=0 and that 0 <= p <= 1.
x.dtype -> numpy dtype
The type of scalars produced by this binomial distribution.
x.p -> scalar
This value corresponds to the parameter p of the distribution.
After calling this method, subsequent uses of the distribution do not depend on values produced by any random number generator prior to invoking reset.
x.t -> scalar
This value corresponds to the parameter t of the distribution.
Bases: object
discrete(dtype, probabilities) -> new discrete distribution
Models a random discrete distribution
A discrete distribution can only assume certain values, which for this class is defined as a number i in the range [0, len(probabilities)]. Notice that the condition \sum(P) = 1, with P = probabilities, is enforced by normalizing the input values so that the sum over all probabilities always equals 1.
x.dtype -> numpy dtype
The type of scalars produced by this discrete distribution.
x.probabilities -> sequence
This property corresponds to the values you have set for the discrete probabilities of every entry in this distribution.
After calling this method, subsequent uses of the distribution do not depend on values produced by any random number generator prior to invoking reset.
Bases: object
gamma(dtype, [alpha=1.]]) -> new gamma distribution
Models a random gamma distribution
This distribution class models a gamma random distribution. Such a distribution produces random numbers x distributed with the probability density function p(x) = x^{\alpha-1}\frac{e^{-x}}{\Gamma(\alpha)}, where the alpha (\alpha) is a parameter of the distribution.
x.alpha -> scalar
This value corresponds to the alpha parameter the distribution current has.
x.dtype -> numpy dtype
The type of scalars produced by this gamma distribution.
After calling this method, subsequent uses of the distribution do not depend on values produced by any random number generator prior to invoking reset.
Bases: object
lognormal(dtype, [mean=0., sigma=1.]]) -> new log-normal distribution
Models a random lognormal distribution
This distribution models a log-normal random distribution. Such a distribution produces random numbers x distributed with the probability density function p(x) = \frac{1}{x \sigma_N \sqrt{2\pi}} e^{\frac{-\left(\log(x)-\mu_N\right)^2}{2\sigma_N^2}}, for x > 0 and \sigma_N = \sqrt{\log\left(1 + \frac{\sigma^2}{\mu^2}\right)},
where the mean (\mu) and sigma (\sigma, the standard deviation) the parameters of the distribution.
x.dtype -> numpy dtype
The type of scalars produced by this lognormal distribution.
x.mean -> scalar
This value corresponds to the mean value the distribution will produce.
After calling this method, subsequent uses of the distribution do not depend on values produced by any random number generator prior to invoking reset.
x.sigma -> scalar
This value corresponds to the standard deviation value the distribution will have.
Bases: object
mt19937([seed]) -> new random number generator
A Mersenne-Twister Random Number Generator (RNG)
Constructor parameters:
A Random Number Generator (RNG) based on the work “Mersenne Twister: A 623-dimensionally equidistributed uniform pseudo-random number generator, Makoto Matsumoto and Takuji Nishimura, ACM Transactions on Modeling and Computer Simulation: Special Issue on Uniform Random Number Generation, Vol. 8, No. 1, January 1998, pp. 3-30“
Objects of this class support comparison operators such as == or != and setting the seed with the method seed(int). Two random number generators are equal if they are at the same state - i.e. they have been initialized with the same seed and have been called the same number of times for number generation.
Sets the seed for this random number generator
This method sets the seed for this random number generator. The input value needs to be convertible to a long integer.
Bases: object
normal(dtype, [mean=0., sigma=1.]]) -> new normal distribution
Models a random normal distribution
This distribution class models a normal random distribution. Such a distribution produces random numbers x distributed with the probability density function p(x) = \frac{1}{\sqrt{2\pi\sigma}} e^{-\frac{(x-\mu)^2}{2\sigma^2}}, where the mean (\mu) and sigma (\sigma, the standard deviation) the parameters of the distribution.
x.dtype -> numpy dtype
The type of scalars produced by this normal distribution.
x.mean -> scalar
This value corresponds to the mean value the distribution will produce.
After calling this method, subsequent uses of the distribution do not depend on values produced by any random number generator prior to invoking reset.
x.sigma -> scalar
This value corresponds to the standard deviation value the distribution will have.
Bases: object
uniform(dtype, [min=m, max=M]]) -> new uniform distribution
Models a random uniform distribution
On each invocation, it returns a random value uniformly distributed in the set of numbers [min, max] (integer) and [min, max[ (real-valued).
If the values min and max are not given they are assumed to be min=0 and max=9, for integral distributions and min=0.0 and max=1.0 for real-valued distributions.
x.dtype -> numpy dtype
The type of scalars produced by this uniform distribution.
x.max -> scalar
This value corresponds to the largest value that the distribution can produce. Integer uniform distributions are bound at [min, max], while real-valued distributions are bound at [min, max[.
x.min -> scalar
This value corresponds to the smallest value that the distribution can produce.
After calling this method, subsequent uses of the distribution do not depend on values produced by any random number generator prior to invoking reset.
Converts array data type, with optional range squash/expansion.
Function which allows to convert/rescale a array of a given type into another array of a possibly different type with re-scaling. Typically, this can be used to rescale a 16 bit precision grayscale image (2D array) into an 8 bit precision grayscale image.
Keyword Parameters:
- array
- (array) Input array
- dtype
- (object) Any object that can be convertible to a numpy.dtype. Controls the output element type for the returned array.
- dest_range
- (tuple) Determines the range to be deployed at the returned array.
- source_range
- (tuple) Determines the input range that will be used for scaling.
Returns a new array with the same shape as this one, but re-scaled and with its element type as indicated by the user.