← Back
Editing: _odds_ratio.cpython-311.pyc
� d�c�A � � � d dl Zd dlmZ d dlmZ ddlmZ ddlm Z d� Z d� Zd � Zd � Z d� Zd� Zd � Z dd�Z dd�Z G d� d� � Zdd�d�ZdS )� N)�ndtri��brentq� )�nchypergeom_fisher)�ConfidenceIntervalc �� � | d dk r0| d dk r$| d | d z | d | d z z }n1| d dk s| d dk r t j }nt j }|S )z� Given a table [[a, b], [c, d]], compute a*d/(b*c). Return nan if the numerator and denominator are 0. Return inf if just the denominator is 0. )r r r )r r �r r )r r )�np�nan�inf)�table� oddsratios �9/usr/lib/python3/dist-packages/scipy/stats/_odds_ratio.py�_sample_odds_ratior sv � � �T�{�Q���5��;��?�?��$�K�%��+�-��t��u�T�{�1J�K� � � �t��� � �U�4�[�A�-�-��F� � ��F� ��� c �$ � d} | |� � }|dk r|S d}|dk r0||z } | |� � dk r||z } | |� � dk �|}||z }n/||z } | |� � dk r||z } | |� � dk �||z }|}t | ||d�� � }|S )zC Solve func(nc) = 0. func must be an increasing function. g �?r g @g�vIh�%<=)�xtolr )�func�nc�value�factor�lo�his r �_solver s� � � �B��D��H�H�E���z�z�� � �F��q�y�y� �f����d�2�h�h��l�l��&�L�B� �d�2�h�h��l�l� �� �B�Y��� �f����d�2�h�h��l�l��&�L�B� �d�2�h�h��l�l� ��Y�� �� ��b�"�5� )� )� )�B� �Ir c �8 � ���� t ���� fd�� � }|S )a For the given noncentral hypergeometric parameters x, M, n,and N (table[0,0], total, row 0 sum and column 0 sum, resp., of a 2x2 contingency table), find the noncentrality parameter of Fisher's noncentral hypergeometric distribution whose mean is x. c �8 �� t j ���| � � �z S �N)r �mean)r �M�N�n�xs ����r �<lambda>z,_nc_hypergeom_mean_inverse.<locals>.<lambda>D s �� �-�2�1�a��B�?�?�!�C� r )r )r# r r"