Package parsimony :: Package algorithms :: Module utils :: Class NewtonRaphson
[hide private]
[frames] | no frames]

Class NewtonRaphson

source code

            object --+        
                     |        
   bases.BaseAlgorithm --+    
                         |    
   bases.ExplicitAlgorithm --+
                             |
                object --+   |
                         |   |
  bases.IterativeAlgorithm --+
                             |
                object --+   |
                         |   |
bases.InformationAlgorithm --+
                             |
                            NewtonRaphson

Finds a root of the function assumed to be in the vicinity of a given
point.

Newtons method is not guaranteed to converge, and may diverge from the
solution if e.g. the starting point is too far from the root.

Problems may also arise if the gradient is too small (e.g. at a stationary
point) on the path to the root.

Parameters
----------
force_negative : Boolean. Default is False. Will try to make the result
        negative. It may fail if the function does not behave "nicely"
        around the found point.

eps : Positive float. A small value used as the stopping criterion. The
        stopping criterion will be fulfilled if it converges in less
        than max_iter iterations.

info : List or tuple of utils.Info. What, if any, extra run
        information should be stored. Default is an empty list, which means
        that no run information is computed nor returned.

max_iter : Non-negative integer. Maximum allowed number of iterations.

min_iter : Non-negative integer less than or equal to max_iter. Minimum
        number of iterations that must be performed. Default is 1.

Instance Methods [hide private]
 
__init__(self, force_negative=False, parameter_positive=True, parameter_negative=True, parameter_zero=True, eps=5e-08, info=[], max_iter=30, min_iter=1)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
run(self, function, *args, **kwargs)
Parameters ---------- function : Function.
source code

Inherited from bases.BaseAlgorithm: get_params, set_params

Inherited from bases.IterativeAlgorithm: iter_reset

Inherited from bases.InformationAlgorithm: check_info_compatibility, info_copy, info_get, info_provided, info_requested, info_reset, info_set

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

Static Methods [hide private]

Inherited from bases.BaseAlgorithm: check_compatibility

Class Variables [hide private]
  INTERFACES = [<class 'parsimony.functions.properties.Function'...
  INFO_PROVIDED = ['ok', 'num_iter', 'converged']
  __abstractmethods__ = frozenset([])

Inherited from bases.ExplicitAlgorithm: __metaclass__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, force_negative=False, parameter_positive=True, parameter_negative=True, parameter_zero=True, eps=5e-08, info=[], max_iter=30, min_iter=1)
(Constructor)

source code 

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

Overrides: object.__init__
(inherited documentation)

run(self, function, *args, **kwargs)

source code 

Parameters
----------
function : Function. The function for which a root should be found.

x : Float. The starting point of the Newton-Raphson algorithm. Should
        be "close" to the root.

Decorators:
  • @bases.force_reset
  • @bases.check_compatibility
Overrides: bases.ExplicitAlgorithm.run

Class Variable Details [hide private]

INTERFACES

Value:
[<class 'parsimony.functions.properties.Function'>,
 <class 'parsimony.functions.properties.Gradient'>]