σ
ίΘ[c           @` sM   d  Z  d d l m Z m Z m Z m Z d d l Z d g Z d d  Z
 d S(   u:   
Statistic functions used in `~astropy.modeling.fitting`.
i    (   t   absolute_importt   unicode_literalst   divisiont   print_functionNu   leastsquarec         C` sh   | d k r | |  } n | | |  } | d k rK t j | |  d  St j | | |  d  Sd S(   us  
    Least square statistic with optional weights.

    Parameters
    ----------
    measured_vals : `~numpy.ndarray`
        Measured data values.
    updated_model : `~astropy.modeling.Model`
        Model with parameters set by the current iteration of the optimizer.
    weights : `~numpy.ndarray`
        Array of weights to apply to each residual.
    x : `~numpy.ndarray`
        Independent variable "x" to evaluate the model on.
    y : `~numpy.ndarray`, optional
        Independent variable "y" to evaluate the model on, for 2D models.

    Returns
    -------
    res : float
        The sum of least squares.
    i   N(   t   Nonet   npt   sum(   t   measured_valst   updated_modelt   weightst   xt   yt
   model_vals(    (    s9   lib/python2.7/site-packages/astropy/modeling/statistic.pyt   leastsquare   s    (   t   __doc__t
   __future__R    R   R   R   t   numpyR   t   __all__R   R   (    (    (    s9   lib/python2.7/site-packages/astropy/modeling/statistic.pyt   <module>   s   "	