| Server IP : 93.86.61.54 / Your IP : 216.73.216.60 Web Server : Apache/2.4.62 (Ubuntu) System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64 User : www-data ( 33) PHP Version : 8.4.22 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /usr/lib/python3/dist-packages/sympy/stats/__pycache__/ |
Upload File : |
o
�8Va" � @ sn d Z ddlmZmZ ddlmZmZmZmZm Z m
Z
mZ ddlm
Z
mZmZ ddlmZ dd� Zd
d
d�ZdS )z'Tools for arithmetic error propagation.� )�repeat�combinations)�S�Symbol�Add�Mul�simplify�Pow�exp)�RandomSymbol�Variance�
Covariance)� is_randomc C s t | j�dkr| jd S | S )Nr )�len�args)�var� r �8/usr/lib/python3/dist-packages/sympy/stats/error_prop.py�<lambda> � r r Fc
C s� | j }t|�dkr*| |v rtjS t| �rt| ��� S t| t�r'tt | ���� S tjS t|�}t
tt|t
||�t
||���}t| t�rZt|� }|rXdd� t|d�D �}|t|� 7 }|S t| t�r�dd� t||�D �}t| d t|� �}|r�dd� tt|d�t|d��D �}|t|� 7 }|S t| t�r�|d }|d | | |d d } t| �}|S t| t�r�t|d | d �}|S t| �}|S )a� Symbolically propagates variance (`\sigma^2`) for expressions.
This is computed as as seen in [1]_.
Parameters
==========
expr : Expr
A sympy expression to compute the variance for.
consts : sequence of Symbols, optional
Represents symbols that are known constants in the expr,
and thus have zero variance. All symbols not in consts are
assumed to be variant.
include_covar : bool, optional
Flag for whether or not to include covariances, default=False.
Returns
=======
var_expr : Expr
An expression for the total variance of the expr.
The variance for the original symbols (e.g. x) are represented
via instance of the Variance symbol (e.g. Variance(x)).
Examples
========
>>> from sympy import symbols, exp
>>> from sympy.stats.error_prop import variance_prop
>>> x, y = symbols('x y')
>>> variance_prop(x + y)
Variance(x) + Variance(y)
>>> variance_prop(x * y)
x**2*Variance(y) + y**2*Variance(x)
>>> variance_prop(exp(2*x))
4*exp(4*x)*Variance(x)
References
==========
.. [1] https://en.wikipedia.org/wiki/Propagation_of_uncertainty
r c S s* g | ]\}}d t t|�t|���� �qS �� �r
�_arg0_or_var�expand)�.0�x�yr r r �
<listcomp>J s �z!variance_prop.<locals>.<listcomp>r c S s g | ]
\}}||d �qS r r )r �a�vr r r r N r c S s: g | ]\\}}\}}d t t|�t|���� || �qS r r )r r �br r r r r r Q s &�� )r r r �Zeror r �doit�
isinstancer r �list�map�
variance_propr r r r �zipr r r
)
�expr�consts�
include_covarr �nargs�var_args�var_expr�termsr! r r r r r( sT .
�
�
�
��
�
��r( N)r F)�__doc__� itertoolsr r �sympyr r r r r r r
� sympy.stats.symbolic_probabilityr r r
�sympy.stats.rvr r r( r r r r �<module> s $