Package parsimony :: Package utils :: Module start_vectors :: Class OnesStartVector
[hide private]
[frames] | no frames]

Class OnesStartVector

source code

     object --+    
              |    
BaseStartVector --+
                  |
                 OnesStartVector

A start vector of ones.

Parameters
----------
normalise : Bool. If True, normalise the randomly created vectors
        Default is False

Examples
--------
>>> from parsimony.utils.start_vectors import OnesStartVector

# Without normalization
>>> start_vector = OnesStartVector(normalise=False)
>>> ones = start_vector.get_vector(3)
>>> print ones
[[ 1.]
 [ 1.]
 [ 1.]]
>>> print maths.norm(ones)
1.73205080757

# With normalization
>>> start_vector_normalized = OnesStartVector(normalise=True)
>>> ones_normalized = start_vector_normalized.get_vector(3)
>>> print ones_normalized
[[ 0.57735027]
 [ 0.57735027]
 [ 0.57735027]]
>>> print maths.norm(ones_normalized)
1.0

Nested Classes [hide private]

Inherited from BaseStartVector: __metaclass__

Instance Methods [hide private]
 
__init__(self, normalise=False, **kwargs)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
get_vector(self, size)
Return vector of ones of chosen shape
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Class Variables [hide private]
  __abstractmethods__ = frozenset([])
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, normalise=False, **kwargs)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

Overrides: object.__init__
(inherited documentation)

get_vector(self, size)

source code 
Return vector of ones of chosen 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 OnesStartVector
>>> start_vector = OnesStartVector()
>>> ones = start_vector.get_vector(3)
>>> print ones
[[ 1.]
 [ 1.]
 [ 1.]]

Overrides: BaseStartVector.get_vector