Home | Trees | Indices | Help |
---|
|
object --+ | BaseStartVector --+ | RandomStartVector
A start vector of uniformly distributed random values. Parameters ---------- normalise : Bool. If True, normalise the randomly created vectors. Default is True. seed : Integer or None. The seed to the pseudo-random number generator. If none, no seed is used. The seed is set at initialisation, so if the RNG is used in between initialisation and utilisation, then the random numbers will change. Default is None. limits : List or tuple. A list or tuple with two elements, the lower and upper limits of the uniform distribution. If normalise=True, then these limits may not be honoured. Default is (0.0, 1.0). Examples -------- >>> from parsimony.utils.start_vectors import RandomStartVector >>> >>> # Without normalization >>> start_vector = RandomStartVector(normalise=False, seed=42) >>> random = start_vector.get_vector(3) >>> print random [[ 0.37454012] [ 0.95071431] [ 0.73199394]] >>> print maths.norm(random) 1.25696186254 >>> >>> # With normalization >>> start_vector_normalized = RandomStartVector(normalise=True, seed=2) >>> random_normalized = start_vector_normalized.get_vector(3) >>> print random_normalized [[ 0.62101956] [ 0.03692864] [ 0.78292463]] >>> print maths.norm(random_normalized) 1.0 >>> >>> # With limits >>> start_vector_normalized = RandomStartVector(normalise=True, seed=2, ... limits=(-1, 1)) >>> random_limits = start_vector_normalized.get_vector(3) >>> print random_limits [[-0.1330817 ] [-0.98571123] [ 0.10326001]] >>> print maths.norm(random_limits) 1.0
|
|||
Inherited from |
|
|||
|
|||
|
|||
Inherited from |
|
|||
__abstractmethods__ =
|
|||
Inherited from |
|
|||
Inherited from |
|
x.__init__(...) initializes x; see help(type(x)) for signature
|
Return randomly generated vector of given shape. Parameters ---------- size : Positive integer. Size of the vector to generate. The shape of the output is (size, 1). Examples -------- >>> from parsimony.utils.start_vectors import RandomStartVector >>> start_vector = RandomStartVector(normalise=False, seed=42) >>> random = start_vector.get_vector(3) >>> print random [[ 0.37454012] [ 0.95071431] [ 0.73199394]] >>> >>> start_vector = RandomStartVector(normalise=False, seed=1, ... limits=(-1, 2)) >>> random = start_vector.get_vector(3) >>> print random [[ 0.25106601] [ 1.16097348] [-0.99965688]]
|
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Mon Apr 6 23:52:11 2015 | http://epydoc.sourceforge.net |