jpt.distributions.univariate.gaussian ===================================== .. py:module:: jpt.distributions.univariate.gaussian Classes ------- .. autoapisummary:: jpt.distributions.univariate.gaussian.Gaussian Module Contents --------------- .. py:class:: Gaussian(mean=None, cov=None, data=None, weights=None) Bases: :py:obj:`dnutils.stats.Gaussian` Extension of :class:`dnutils.stats.Gaussian` Creates a new Gaussian distribution. :param mean: the mean of the Gaussian :type mean: float if multivariate else [float] if multivariate :param cov: the covariance of the Gaussian :type cov: float if multivariate else [[float]] if multivariate :param data: if ``mean`` and ``cov`` are not provided, ``data`` may be a data set (matrix) from which the parameters of the distribution are estimated. :type data: [[float]] :param weights: **[optional]** weights for the data points. The weight do not need to be normalized. :type weights: [float] .. py:attribute:: PRECISION :value: 1e-15 .. py:attribute:: _cl :value: 'jpt.distributions.univariate.gaussian.Gaussian' .. py:attribute:: _sum_w :value: 0 .. py:attribute:: _sum_w_sq :value: 0 .. py:attribute:: _mean .. py:attribute:: _cov .. py:attribute:: data :value: [] .. py:method:: mean() .. py:method:: cov() .. py:method:: var() .. py:property:: std .. py:method:: deviation(x) Computes the deviation of ``x`` in multiples of the standard deviation. :param x: :type x: :returns: .. py:method:: __add__(alpha) .. py:method:: __radd__(other) .. py:method:: __iadd__(other) .. py:method:: __mul__(alpha) .. py:method:: __rmul__(other) .. py:method:: __imul__(other) .. py:method:: wasserstein_distance(d1: Gaussian, d2: Gaussian) -> float :staticmethod: .. py:method:: dim() .. py:method:: sample(n) Return ``n`` samples from this Gaussian distribution. :param n: number of samples :return: array of shape ``(n,)`` for 1-D or ``(n, d)`` for d-dimensional Gaussians .. py:property:: pdf .. py:method:: cdf(*x) .. py:method:: eval(lower, upper) .. py:method:: copy() .. py:method:: __eq__(other) .. py:method:: linreg() Compute a 4-tuple ```` of a linear regression represented by this Gaussian. :return: ``m`` - the slope of the line ``b`` - the intercept of the line ``rss`` - the residual sum-of-squares error ``noise`` - the square of the sample correlation coefficient ``r^2`` References: - https://en.wikipedia.org/wiki/Pearson_correlation_coefficient#In_least_squares_regression_analysis - https://milnepublishing.geneseo.edu/natural-resources-biometrics/chapter/chapter-7-correlation-and-simple-linear-regression/ - https://en.wikipedia.org/wiki/Residual_sum_of_squares - https://en.wikipedia.org/wiki/Explained_sum_of_squares .. py:method:: update_all(data, weights=None) Update the distribution with new data points given in ``data``. .. py:method:: estimate(data, weights=None) Estimate the distribution parameters with subject to the given data points. .. py:method:: update(x, w=1) update the Gaussian distribution with a new data point ``x`` and weight ``w``. .. py:method:: retract(x, w=1) Retract the data point `x` with weight `w` from the Gaussian distribution. In case the data points are being kept in the distribution, it must actually exist and have the right weight associated. Otherwise, a ValueError will be raised. .. py:method:: sym() .. py:method:: plot(engine=None, **kwargs) -> Any Plots the distribution using the given engine. :param engine: Can be either one of ``["plotly", "matplotlib"]``, or an instance of a rendering engine subclassing ``DistributionRendering``. :param kwargs: The keyword arguments to pass to the engine as defined in the ``.plot_gaussian()`` function of ``DistributionRendering`` or its respective subclass defined by ``engine``. :return: the figure object of the plotting engine