diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_bvp.py b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_bvp.py new file mode 100644 index 0000000000000000000000000000000000000000..f988fdd6e0527d3adc4f4edfa955cc33d9eb85f8 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_bvp.py @@ -0,0 +1,1155 @@ +"""Boundary value problem solver.""" +from warnings import warn + +import numpy as np +from numpy.linalg import pinv + +from scipy.sparse import coo_matrix, csc_matrix +from scipy.sparse.linalg import splu +from scipy.optimize import OptimizeResult + + +EPS = np.finfo(float).eps + + +def estimate_fun_jac(fun, x, y, p, f0=None): + """Estimate derivatives of an ODE system rhs with forward differences. + + Returns + ------- + df_dy : ndarray, shape (n, n, m) + Derivatives with respect to y. An element (i, j, q) corresponds to + d f_i(x_q, y_q) / d (y_q)_j. + df_dp : ndarray with shape (n, k, m) or None + Derivatives with respect to p. An element (i, j, q) corresponds to + d f_i(x_q, y_q, p) / d p_j. If `p` is empty, None is returned. + """ + n, m = y.shape + if f0 is None: + f0 = fun(x, y, p) + + dtype = y.dtype + + df_dy = np.empty((n, n, m), dtype=dtype) + h = EPS**0.5 * (1 + np.abs(y)) + for i in range(n): + y_new = y.copy() + y_new[i] += h[i] + hi = y_new[i] - y[i] + f_new = fun(x, y_new, p) + df_dy[:, i, :] = (f_new - f0) / hi + + k = p.shape[0] + if k == 0: + df_dp = None + else: + df_dp = np.empty((n, k, m), dtype=dtype) + h = EPS**0.5 * (1 + np.abs(p)) + for i in range(k): + p_new = p.copy() + p_new[i] += h[i] + hi = p_new[i] - p[i] + f_new = fun(x, y, p_new) + df_dp[:, i, :] = (f_new - f0) / hi + + return df_dy, df_dp + + +def estimate_bc_jac(bc, ya, yb, p, bc0=None): + """Estimate derivatives of boundary conditions with forward differences. + + Returns + ------- + dbc_dya : ndarray, shape (n + k, n) + Derivatives with respect to ya. An element (i, j) corresponds to + d bc_i / d ya_j. + dbc_dyb : ndarray, shape (n + k, n) + Derivatives with respect to yb. An element (i, j) corresponds to + d bc_i / d ya_j. + dbc_dp : ndarray with shape (n + k, k) or None + Derivatives with respect to p. An element (i, j) corresponds to + d bc_i / d p_j. If `p` is empty, None is returned. + """ + n = ya.shape[0] + k = p.shape[0] + + if bc0 is None: + bc0 = bc(ya, yb, p) + + dtype = ya.dtype + + dbc_dya = np.empty((n, n + k), dtype=dtype) + h = EPS**0.5 * (1 + np.abs(ya)) + for i in range(n): + ya_new = ya.copy() + ya_new[i] += h[i] + hi = ya_new[i] - ya[i] + bc_new = bc(ya_new, yb, p) + dbc_dya[i] = (bc_new - bc0) / hi + dbc_dya = dbc_dya.T + + h = EPS**0.5 * (1 + np.abs(yb)) + dbc_dyb = np.empty((n, n + k), dtype=dtype) + for i in range(n): + yb_new = yb.copy() + yb_new[i] += h[i] + hi = yb_new[i] - yb[i] + bc_new = bc(ya, yb_new, p) + dbc_dyb[i] = (bc_new - bc0) / hi + dbc_dyb = dbc_dyb.T + + if k == 0: + dbc_dp = None + else: + h = EPS**0.5 * (1 + np.abs(p)) + dbc_dp = np.empty((k, n + k), dtype=dtype) + for i in range(k): + p_new = p.copy() + p_new[i] += h[i] + hi = p_new[i] - p[i] + bc_new = bc(ya, yb, p_new) + dbc_dp[i] = (bc_new - bc0) / hi + dbc_dp = dbc_dp.T + + return dbc_dya, dbc_dyb, dbc_dp + + +def compute_jac_indices(n, m, k): + """Compute indices for the collocation system Jacobian construction. + + See `construct_global_jac` for the explanation. + """ + i_col = np.repeat(np.arange((m - 1) * n), n) + j_col = (np.tile(np.arange(n), n * (m - 1)) + + np.repeat(np.arange(m - 1) * n, n**2)) + + i_bc = np.repeat(np.arange((m - 1) * n, m * n + k), n) + j_bc = np.tile(np.arange(n), n + k) + + i_p_col = np.repeat(np.arange((m - 1) * n), k) + j_p_col = np.tile(np.arange(m * n, m * n + k), (m - 1) * n) + + i_p_bc = np.repeat(np.arange((m - 1) * n, m * n + k), k) + j_p_bc = np.tile(np.arange(m * n, m * n + k), n + k) + + i = np.hstack((i_col, i_col, i_bc, i_bc, i_p_col, i_p_bc)) + j = np.hstack((j_col, j_col + n, + j_bc, j_bc + (m - 1) * n, + j_p_col, j_p_bc)) + + return i, j + + +def stacked_matmul(a, b): + """Stacked matrix multiply: out[i,:,:] = np.dot(a[i,:,:], b[i,:,:]). + + Empirical optimization. Use outer Python loop and BLAS for large + matrices, otherwise use a single einsum call. + """ + if a.shape[1] > 50: + out = np.empty((a.shape[0], a.shape[1], b.shape[2])) + for i in range(a.shape[0]): + out[i] = np.dot(a[i], b[i]) + return out + else: + return np.einsum('...ij,...jk->...ik', a, b) + + +def construct_global_jac(n, m, k, i_jac, j_jac, h, df_dy, df_dy_middle, df_dp, + df_dp_middle, dbc_dya, dbc_dyb, dbc_dp): + """Construct the Jacobian of the collocation system. + + There are n * m + k functions: m - 1 collocations residuals, each + containing n components, followed by n + k boundary condition residuals. + + There are n * m + k variables: m vectors of y, each containing n + components, followed by k values of vector p. + + For example, let m = 4, n = 2 and k = 1, then the Jacobian will have + the following sparsity structure: + + 1 1 2 2 0 0 0 0 5 + 1 1 2 2 0 0 0 0 5 + 0 0 1 1 2 2 0 0 5 + 0 0 1 1 2 2 0 0 5 + 0 0 0 0 1 1 2 2 5 + 0 0 0 0 1 1 2 2 5 + + 3 3 0 0 0 0 4 4 6 + 3 3 0 0 0 0 4 4 6 + 3 3 0 0 0 0 4 4 6 + + Zeros denote identically zero values, other values denote different kinds + of blocks in the matrix (see below). The blank row indicates the separation + of collocation residuals from boundary conditions. And the blank column + indicates the separation of y values from p values. + + Refer to [1]_ (p. 306) for the formula of n x n blocks for derivatives + of collocation residuals with respect to y. + + Parameters + ---------- + n : int + Number of equations in the ODE system. + m : int + Number of nodes in the mesh. + k : int + Number of the unknown parameters. + i_jac, j_jac : ndarray + Row and column indices returned by `compute_jac_indices`. They + represent different blocks in the Jacobian matrix in the following + order (see the scheme above): + + * 1: m - 1 diagonal n x n blocks for the collocation residuals. + * 2: m - 1 off-diagonal n x n blocks for the collocation residuals. + * 3 : (n + k) x n block for the dependency of the boundary + conditions on ya. + * 4: (n + k) x n block for the dependency of the boundary + conditions on yb. + * 5: (m - 1) * n x k block for the dependency of the collocation + residuals on p. + * 6: (n + k) x k block for the dependency of the boundary + conditions on p. + + df_dy : ndarray, shape (n, n, m) + Jacobian of f with respect to y computed at the mesh nodes. + df_dy_middle : ndarray, shape (n, n, m - 1) + Jacobian of f with respect to y computed at the middle between the + mesh nodes. + df_dp : ndarray with shape (n, k, m) or None + Jacobian of f with respect to p computed at the mesh nodes. + df_dp_middle : ndarray with shape (n, k, m - 1) or None + Jacobian of f with respect to p computed at the middle between the + mesh nodes. + dbc_dya, dbc_dyb : ndarray, shape (n, n) + Jacobian of bc with respect to ya and yb. + dbc_dp : ndarray with shape (n, k) or None + Jacobian of bc with respect to p. + + Returns + ------- + J : csc_matrix, shape (n * m + k, n * m + k) + Jacobian of the collocation system in a sparse form. + + References + ---------- + .. [1] J. Kierzenka, L. F. Shampine, "A BVP Solver Based on Residual + Control and the Maltab PSE", ACM Trans. Math. Softw., Vol. 27, + Number 3, pp. 299-316, 2001. + """ + df_dy = np.transpose(df_dy, (2, 0, 1)) + df_dy_middle = np.transpose(df_dy_middle, (2, 0, 1)) + + h = h[:, np.newaxis, np.newaxis] + + dtype = df_dy.dtype + + # Computing diagonal n x n blocks. + dPhi_dy_0 = np.empty((m - 1, n, n), dtype=dtype) + dPhi_dy_0[:] = -np.identity(n) + dPhi_dy_0 -= h / 6 * (df_dy[:-1] + 2 * df_dy_middle) + T = stacked_matmul(df_dy_middle, df_dy[:-1]) + dPhi_dy_0 -= h**2 / 12 * T + + # Computing off-diagonal n x n blocks. + dPhi_dy_1 = np.empty((m - 1, n, n), dtype=dtype) + dPhi_dy_1[:] = np.identity(n) + dPhi_dy_1 -= h / 6 * (df_dy[1:] + 2 * df_dy_middle) + T = stacked_matmul(df_dy_middle, df_dy[1:]) + dPhi_dy_1 += h**2 / 12 * T + + values = np.hstack((dPhi_dy_0.ravel(), dPhi_dy_1.ravel(), dbc_dya.ravel(), + dbc_dyb.ravel())) + + if k > 0: + df_dp = np.transpose(df_dp, (2, 0, 1)) + df_dp_middle = np.transpose(df_dp_middle, (2, 0, 1)) + T = stacked_matmul(df_dy_middle, df_dp[:-1] - df_dp[1:]) + df_dp_middle += 0.125 * h * T + dPhi_dp = -h/6 * (df_dp[:-1] + df_dp[1:] + 4 * df_dp_middle) + values = np.hstack((values, dPhi_dp.ravel(), dbc_dp.ravel())) + + J = coo_matrix((values, (i_jac, j_jac))) + return csc_matrix(J) + + +def collocation_fun(fun, y, p, x, h): + """Evaluate collocation residuals. + + This function lies in the core of the method. The solution is sought + as a cubic C1 continuous spline with derivatives matching the ODE rhs + at given nodes `x`. Collocation conditions are formed from the equality + of the spline derivatives and rhs of the ODE system in the middle points + between nodes. + + Such method is classified to Lobbato IIIA family in ODE literature. + Refer to [1]_ for the formula and some discussion. + + Returns + ------- + col_res : ndarray, shape (n, m - 1) + Collocation residuals at the middle points of the mesh intervals. + y_middle : ndarray, shape (n, m - 1) + Values of the cubic spline evaluated at the middle points of the mesh + intervals. + f : ndarray, shape (n, m) + RHS of the ODE system evaluated at the mesh nodes. + f_middle : ndarray, shape (n, m - 1) + RHS of the ODE system evaluated at the middle points of the mesh + intervals (and using `y_middle`). + + References + ---------- + .. [1] J. Kierzenka, L. F. Shampine, "A BVP Solver Based on Residual + Control and the Maltab PSE", ACM Trans. Math. Softw., Vol. 27, + Number 3, pp. 299-316, 2001. + """ + f = fun(x, y, p) + y_middle = (0.5 * (y[:, 1:] + y[:, :-1]) - + 0.125 * h * (f[:, 1:] - f[:, :-1])) + f_middle = fun(x[:-1] + 0.5 * h, y_middle, p) + col_res = y[:, 1:] - y[:, :-1] - h / 6 * (f[:, :-1] + f[:, 1:] + + 4 * f_middle) + + return col_res, y_middle, f, f_middle + + +def prepare_sys(n, m, k, fun, bc, fun_jac, bc_jac, x, h): + """Create the function and the Jacobian for the collocation system.""" + x_middle = x[:-1] + 0.5 * h + i_jac, j_jac = compute_jac_indices(n, m, k) + + def col_fun(y, p): + return collocation_fun(fun, y, p, x, h) + + def sys_jac(y, p, y_middle, f, f_middle, bc0): + if fun_jac is None: + df_dy, df_dp = estimate_fun_jac(fun, x, y, p, f) + df_dy_middle, df_dp_middle = estimate_fun_jac( + fun, x_middle, y_middle, p, f_middle) + else: + df_dy, df_dp = fun_jac(x, y, p) + df_dy_middle, df_dp_middle = fun_jac(x_middle, y_middle, p) + + if bc_jac is None: + dbc_dya, dbc_dyb, dbc_dp = estimate_bc_jac(bc, y[:, 0], y[:, -1], + p, bc0) + else: + dbc_dya, dbc_dyb, dbc_dp = bc_jac(y[:, 0], y[:, -1], p) + + return construct_global_jac(n, m, k, i_jac, j_jac, h, df_dy, + df_dy_middle, df_dp, df_dp_middle, dbc_dya, + dbc_dyb, dbc_dp) + + return col_fun, sys_jac + + +def solve_newton(n, m, h, col_fun, bc, jac, y, p, B, bvp_tol, bc_tol): + """Solve the nonlinear collocation system by a Newton method. + + This is a simple Newton method with a backtracking line search. As + advised in [1]_, an affine-invariant criterion function F = ||J^-1 r||^2 + is used, where J is the Jacobian matrix at the current iteration and r is + the vector or collocation residuals (values of the system lhs). + + The method alters between full Newton iterations and the fixed-Jacobian + iterations based + + There are other tricks proposed in [1]_, but they are not used as they + don't seem to improve anything significantly, and even break the + convergence on some test problems I tried. + + All important parameters of the algorithm are defined inside the function. + + Parameters + ---------- + n : int + Number of equations in the ODE system. + m : int + Number of nodes in the mesh. + h : ndarray, shape (m-1,) + Mesh intervals. + col_fun : callable + Function computing collocation residuals. + bc : callable + Function computing boundary condition residuals. + jac : callable + Function computing the Jacobian of the whole system (including + collocation and boundary condition residuals). It is supposed to + return csc_matrix. + y : ndarray, shape (n, m) + Initial guess for the function values at the mesh nodes. + p : ndarray, shape (k,) + Initial guess for the unknown parameters. + B : ndarray with shape (n, n) or None + Matrix to force the S y(a) = 0 condition for a problems with the + singular term. If None, the singular term is assumed to be absent. + bvp_tol : float + Tolerance to which we want to solve a BVP. + bc_tol : float + Tolerance to which we want to satisfy the boundary conditions. + + Returns + ------- + y : ndarray, shape (n, m) + Final iterate for the function values at the mesh nodes. + p : ndarray, shape (k,) + Final iterate for the unknown parameters. + singular : bool + True, if the LU decomposition failed because Jacobian turned out + to be singular. + + References + ---------- + .. [1] U. Ascher, R. Mattheij and R. Russell "Numerical Solution of + Boundary Value Problems for Ordinary Differential Equations" + """ + # We know that the solution residuals at the middle points of the mesh + # are connected with collocation residuals r_middle = 1.5 * col_res / h. + # As our BVP solver tries to decrease relative residuals below a certain + # tolerance, it seems reasonable to terminated Newton iterations by + # comparison of r_middle / (1 + np.abs(f_middle)) with a certain threshold, + # which we choose to be 1.5 orders lower than the BVP tolerance. We rewrite + # the condition as col_res < tol_r * (1 + np.abs(f_middle)), then tol_r + # should be computed as follows: + tol_r = 2/3 * h * 5e-2 * bvp_tol + + # Maximum allowed number of Jacobian evaluation and factorization, in + # other words, the maximum number of full Newton iterations. A small value + # is recommended in the literature. + max_njev = 4 + + # Maximum number of iterations, considering that some of them can be + # performed with the fixed Jacobian. In theory, such iterations are cheap, + # but it's not that simple in Python. + max_iter = 8 + + # Minimum relative improvement of the criterion function to accept the + # step (Armijo constant). + sigma = 0.2 + + # Step size decrease factor for backtracking. + tau = 0.5 + + # Maximum number of backtracking steps, the minimum step is then + # tau ** n_trial. + n_trial = 4 + + col_res, y_middle, f, f_middle = col_fun(y, p) + bc_res = bc(y[:, 0], y[:, -1], p) + res = np.hstack((col_res.ravel(order='F'), bc_res)) + + njev = 0 + singular = False + recompute_jac = True + for iteration in range(max_iter): + if recompute_jac: + J = jac(y, p, y_middle, f, f_middle, bc_res) + njev += 1 + try: + LU = splu(J) + except RuntimeError: + singular = True + break + + step = LU.solve(res) + cost = np.dot(step, step) + + y_step = step[:m * n].reshape((n, m), order='F') + p_step = step[m * n:] + + alpha = 1 + for trial in range(n_trial + 1): + y_new = y - alpha * y_step + if B is not None: + y_new[:, 0] = np.dot(B, y_new[:, 0]) + p_new = p - alpha * p_step + + col_res, y_middle, f, f_middle = col_fun(y_new, p_new) + bc_res = bc(y_new[:, 0], y_new[:, -1], p_new) + res = np.hstack((col_res.ravel(order='F'), bc_res)) + + step_new = LU.solve(res) + cost_new = np.dot(step_new, step_new) + if cost_new < (1 - 2 * alpha * sigma) * cost: + break + + if trial < n_trial: + alpha *= tau + + y = y_new + p = p_new + + if njev == max_njev: + break + + if (np.all(np.abs(col_res) < tol_r * (1 + np.abs(f_middle))) and + np.all(np.abs(bc_res) < bc_tol)): + break + + # If the full step was taken, then we are going to continue with + # the same Jacobian. This is the approach of BVP_SOLVER. + if alpha == 1: + step = step_new + cost = cost_new + recompute_jac = False + else: + recompute_jac = True + + return y, p, singular + + +def print_iteration_header(): + print("{:^15}{:^15}{:^15}{:^15}{:^15}".format( + "Iteration", "Max residual", "Max BC residual", "Total nodes", + "Nodes added")) + + +def print_iteration_progress(iteration, residual, bc_residual, total_nodes, + nodes_added): + print("{:^15}{:^15.2e}{:^15.2e}{:^15}{:^15}".format( + iteration, residual, bc_residual, total_nodes, nodes_added)) + + +class BVPResult(OptimizeResult): + pass + + +TERMINATION_MESSAGES = { + 0: "The algorithm converged to the desired accuracy.", + 1: "The maximum number of mesh nodes is exceeded.", + 2: "A singular Jacobian encountered when solving the collocation system.", + 3: "The solver was unable to satisfy boundary conditions tolerance on iteration 10." +} + + +def estimate_rms_residuals(fun, sol, x, h, p, r_middle, f_middle): + """Estimate rms values of collocation residuals using Lobatto quadrature. + + The residuals are defined as the difference between the derivatives of + our solution and rhs of the ODE system. We use relative residuals, i.e., + normalized by 1 + np.abs(f). RMS values are computed as sqrt from the + normalized integrals of the squared relative residuals over each interval. + Integrals are estimated using 5-point Lobatto quadrature [1]_, we use the + fact that residuals at the mesh nodes are identically zero. + + In [2] they don't normalize integrals by interval lengths, which gives + a higher rate of convergence of the residuals by the factor of h**0.5. + I chose to do such normalization for an ease of interpretation of return + values as RMS estimates. + + Returns + ------- + rms_res : ndarray, shape (m - 1,) + Estimated rms values of the relative residuals over each interval. + + References + ---------- + .. [1] http://mathworld.wolfram.com/LobattoQuadrature.html + .. [2] J. Kierzenka, L. F. Shampine, "A BVP Solver Based on Residual + Control and the Maltab PSE", ACM Trans. Math. Softw., Vol. 27, + Number 3, pp. 299-316, 2001. + """ + x_middle = x[:-1] + 0.5 * h + s = 0.5 * h * (3/7)**0.5 + x1 = x_middle + s + x2 = x_middle - s + y1 = sol(x1) + y2 = sol(x2) + y1_prime = sol(x1, 1) + y2_prime = sol(x2, 1) + f1 = fun(x1, y1, p) + f2 = fun(x2, y2, p) + r1 = y1_prime - f1 + r2 = y2_prime - f2 + + r_middle /= 1 + np.abs(f_middle) + r1 /= 1 + np.abs(f1) + r2 /= 1 + np.abs(f2) + + r1 = np.sum(np.real(r1 * np.conj(r1)), axis=0) + r2 = np.sum(np.real(r2 * np.conj(r2)), axis=0) + r_middle = np.sum(np.real(r_middle * np.conj(r_middle)), axis=0) + + return (0.5 * (32 / 45 * r_middle + 49 / 90 * (r1 + r2))) ** 0.5 + + +def create_spline(y, yp, x, h): + """Create a cubic spline given values and derivatives. + + Formulas for the coefficients are taken from interpolate.CubicSpline. + + Returns + ------- + sol : PPoly + Constructed spline as a PPoly instance. + """ + from scipy.interpolate import PPoly + + n, m = y.shape + c = np.empty((4, n, m - 1), dtype=y.dtype) + slope = (y[:, 1:] - y[:, :-1]) / h + t = (yp[:, :-1] + yp[:, 1:] - 2 * slope) / h + c[0] = t / h + c[1] = (slope - yp[:, :-1]) / h - t + c[2] = yp[:, :-1] + c[3] = y[:, :-1] + c = np.moveaxis(c, 1, 0) + + return PPoly(c, x, extrapolate=True, axis=1) + + +def modify_mesh(x, insert_1, insert_2): + """Insert nodes into a mesh. + + Nodes removal logic is not established, its impact on the solver is + presumably negligible. So, only insertion is done in this function. + + Parameters + ---------- + x : ndarray, shape (m,) + Mesh nodes. + insert_1 : ndarray + Intervals to each insert 1 new node in the middle. + insert_2 : ndarray + Intervals to each insert 2 new nodes, such that divide an interval + into 3 equal parts. + + Returns + ------- + x_new : ndarray + New mesh nodes. + + Notes + ----- + `insert_1` and `insert_2` should not have common values. + """ + # Because np.insert implementation apparently varies with a version of + # NumPy, we use a simple and reliable approach with sorting. + return np.sort(np.hstack(( + x, + 0.5 * (x[insert_1] + x[insert_1 + 1]), + (2 * x[insert_2] + x[insert_2 + 1]) / 3, + (x[insert_2] + 2 * x[insert_2 + 1]) / 3 + ))) + + +def wrap_functions(fun, bc, fun_jac, bc_jac, k, a, S, D, dtype): + """Wrap functions for unified usage in the solver.""" + if fun_jac is None: + fun_jac_wrapped = None + + if bc_jac is None: + bc_jac_wrapped = None + + if k == 0: + def fun_p(x, y, _): + return np.asarray(fun(x, y), dtype) + + def bc_wrapped(ya, yb, _): + return np.asarray(bc(ya, yb), dtype) + + if fun_jac is not None: + def fun_jac_p(x, y, _): + return np.asarray(fun_jac(x, y), dtype), None + + if bc_jac is not None: + def bc_jac_wrapped(ya, yb, _): + dbc_dya, dbc_dyb = bc_jac(ya, yb) + return (np.asarray(dbc_dya, dtype), + np.asarray(dbc_dyb, dtype), None) + else: + def fun_p(x, y, p): + return np.asarray(fun(x, y, p), dtype) + + def bc_wrapped(x, y, p): + return np.asarray(bc(x, y, p), dtype) + + if fun_jac is not None: + def fun_jac_p(x, y, p): + df_dy, df_dp = fun_jac(x, y, p) + return np.asarray(df_dy, dtype), np.asarray(df_dp, dtype) + + if bc_jac is not None: + def bc_jac_wrapped(ya, yb, p): + dbc_dya, dbc_dyb, dbc_dp = bc_jac(ya, yb, p) + return (np.asarray(dbc_dya, dtype), np.asarray(dbc_dyb, dtype), + np.asarray(dbc_dp, dtype)) + + if S is None: + fun_wrapped = fun_p + else: + def fun_wrapped(x, y, p): + f = fun_p(x, y, p) + if x[0] == a: + f[:, 0] = np.dot(D, f[:, 0]) + f[:, 1:] += np.dot(S, y[:, 1:]) / (x[1:] - a) + else: + f += np.dot(S, y) / (x - a) + return f + + if fun_jac is not None: + if S is None: + fun_jac_wrapped = fun_jac_p + else: + Sr = S[:, :, np.newaxis] + + def fun_jac_wrapped(x, y, p): + df_dy, df_dp = fun_jac_p(x, y, p) + if x[0] == a: + df_dy[:, :, 0] = np.dot(D, df_dy[:, :, 0]) + df_dy[:, :, 1:] += Sr / (x[1:] - a) + else: + df_dy += Sr / (x - a) + + return df_dy, df_dp + + return fun_wrapped, bc_wrapped, fun_jac_wrapped, bc_jac_wrapped + + +def solve_bvp(fun, bc, x, y, p=None, S=None, fun_jac=None, bc_jac=None, + tol=1e-3, max_nodes=1000, verbose=0, bc_tol=None): + """Solve a boundary value problem for a system of ODEs. + + This function numerically solves a first order system of ODEs subject to + two-point boundary conditions:: + + dy / dx = f(x, y, p) + S * y / (x - a), a <= x <= b + bc(y(a), y(b), p) = 0 + + Here x is a 1-D independent variable, y(x) is an N-D + vector-valued function and p is a k-D vector of unknown + parameters which is to be found along with y(x). For the problem to be + determined, there must be n + k boundary conditions, i.e., bc must be an + (n + k)-D function. + + The last singular term on the right-hand side of the system is optional. + It is defined by an n-by-n matrix S, such that the solution must satisfy + S y(a) = 0. This condition will be forced during iterations, so it must not + contradict boundary conditions. See [2]_ for the explanation how this term + is handled when solving BVPs numerically. + + Problems in a complex domain can be solved as well. In this case, y and p + are considered to be complex, and f and bc are assumed to be complex-valued + functions, but x stays real. Note that f and bc must be complex + differentiable (satisfy Cauchy-Riemann equations [4]_), otherwise you + should rewrite your problem for real and imaginary parts separately. To + solve a problem in a complex domain, pass an initial guess for y with a + complex data type (see below). + + Parameters + ---------- + fun : callable + Right-hand side of the system. The calling signature is ``fun(x, y)``, + or ``fun(x, y, p)`` if parameters are present. All arguments are + ndarray: ``x`` with shape (m,), ``y`` with shape (n, m), meaning that + ``y[:, i]`` corresponds to ``x[i]``, and ``p`` with shape (k,). The + return value must be an array with shape (n, m) and with the same + layout as ``y``. + bc : callable + Function evaluating residuals of the boundary conditions. The calling + signature is ``bc(ya, yb)``, or ``bc(ya, yb, p)`` if parameters are + present. All arguments are ndarray: ``ya`` and ``yb`` with shape (n,), + and ``p`` with shape (k,). The return value must be an array with + shape (n + k,). + x : array_like, shape (m,) + Initial mesh. Must be a strictly increasing sequence of real numbers + with ``x[0]=a`` and ``x[-1]=b``. + y : array_like, shape (n, m) + Initial guess for the function values at the mesh nodes, ith column + corresponds to ``x[i]``. For problems in a complex domain pass `y` + with a complex data type (even if the initial guess is purely real). + p : array_like with shape (k,) or None, optional + Initial guess for the unknown parameters. If None (default), it is + assumed that the problem doesn't depend on any parameters. + S : array_like with shape (n, n) or None + Matrix defining the singular term. If None (default), the problem is + solved without the singular term. + fun_jac : callable or None, optional + Function computing derivatives of f with respect to y and p. The + calling signature is ``fun_jac(x, y)``, or ``fun_jac(x, y, p)`` if + parameters are present. The return must contain 1 or 2 elements in the + following order: + + * df_dy : array_like with shape (n, n, m), where an element + (i, j, q) equals to d f_i(x_q, y_q, p) / d (y_q)_j. + * df_dp : array_like with shape (n, k, m), where an element + (i, j, q) equals to d f_i(x_q, y_q, p) / d p_j. + + Here q numbers nodes at which x and y are defined, whereas i and j + number vector components. If the problem is solved without unknown + parameters, df_dp should not be returned. + + If `fun_jac` is None (default), the derivatives will be estimated + by the forward finite differences. + bc_jac : callable or None, optional + Function computing derivatives of bc with respect to ya, yb, and p. + The calling signature is ``bc_jac(ya, yb)``, or ``bc_jac(ya, yb, p)`` + if parameters are present. The return must contain 2 or 3 elements in + the following order: + + * dbc_dya : array_like with shape (n, n), where an element (i, j) + equals to d bc_i(ya, yb, p) / d ya_j. + * dbc_dyb : array_like with shape (n, n), where an element (i, j) + equals to d bc_i(ya, yb, p) / d yb_j. + * dbc_dp : array_like with shape (n, k), where an element (i, j) + equals to d bc_i(ya, yb, p) / d p_j. + + If the problem is solved without unknown parameters, dbc_dp should not + be returned. + + If `bc_jac` is None (default), the derivatives will be estimated by + the forward finite differences. + tol : float, optional + Desired tolerance of the solution. If we define ``r = y' - f(x, y)``, + where y is the found solution, then the solver tries to achieve on each + mesh interval ``norm(r / (1 + abs(f)) < tol``, where ``norm`` is + estimated in a root mean squared sense (using a numerical quadrature + formula). Default is 1e-3. + max_nodes : int, optional + Maximum allowed number of the mesh nodes. If exceeded, the algorithm + terminates. Default is 1000. + verbose : {0, 1, 2}, optional + Level of algorithm's verbosity: + + * 0 (default) : work silently. + * 1 : display a termination report. + * 2 : display progress during iterations. + bc_tol : float, optional + Desired absolute tolerance for the boundary condition residuals: `bc` + value should satisfy ``abs(bc) < bc_tol`` component-wise. + Equals to `tol` by default. Up to 10 iterations are allowed to achieve this + tolerance. + + Returns + ------- + Bunch object with the following fields defined: + sol : PPoly + Found solution for y as `scipy.interpolate.PPoly` instance, a C1 + continuous cubic spline. + p : ndarray or None, shape (k,) + Found parameters. None, if the parameters were not present in the + problem. + x : ndarray, shape (m,) + Nodes of the final mesh. + y : ndarray, shape (n, m) + Solution values at the mesh nodes. + yp : ndarray, shape (n, m) + Solution derivatives at the mesh nodes. + rms_residuals : ndarray, shape (m - 1,) + RMS values of the relative residuals over each mesh interval (see the + description of `tol` parameter). + niter : int + Number of completed iterations. + status : int + Reason for algorithm termination: + + * 0: The algorithm converged to the desired accuracy. + * 1: The maximum number of mesh nodes is exceeded. + * 2: A singular Jacobian encountered when solving the collocation + system. + + message : string + Verbal description of the termination reason. + success : bool + True if the algorithm converged to the desired accuracy (``status=0``). + + Notes + ----- + This function implements a 4th order collocation algorithm with the + control of residuals similar to [1]_. A collocation system is solved + by a damped Newton method with an affine-invariant criterion function as + described in [3]_. + + Note that in [1]_ integral residuals are defined without normalization + by interval lengths. So, their definition is different by a multiplier of + h**0.5 (h is an interval length) from the definition used here. + + .. versionadded:: 0.18.0 + + References + ---------- + .. [1] J. Kierzenka, L. F. Shampine, "A BVP Solver Based on Residual + Control and the Maltab PSE", ACM Trans. Math. Softw., Vol. 27, + Number 3, pp. 299-316, 2001. + .. [2] L.F. Shampine, P. H. Muir and H. Xu, "A User-Friendly Fortran BVP + Solver". + .. [3] U. Ascher, R. Mattheij and R. Russell "Numerical Solution of + Boundary Value Problems for Ordinary Differential Equations". + .. [4] `Cauchy-Riemann equations + `_ on + Wikipedia. + + Examples + -------- + In the first example, we solve Bratu's problem:: + + y'' + k * exp(y) = 0 + y(0) = y(1) = 0 + + for k = 1. + + We rewrite the equation as a first-order system and implement its + right-hand side evaluation:: + + y1' = y2 + y2' = -exp(y1) + + >>> import numpy as np + >>> def fun(x, y): + ... return np.vstack((y[1], -np.exp(y[0]))) + + Implement evaluation of the boundary condition residuals: + + >>> def bc(ya, yb): + ... return np.array([ya[0], yb[0]]) + + Define the initial mesh with 5 nodes: + + >>> x = np.linspace(0, 1, 5) + + This problem is known to have two solutions. To obtain both of them, we + use two different initial guesses for y. We denote them by subscripts + a and b. + + >>> y_a = np.zeros((2, x.size)) + >>> y_b = np.zeros((2, x.size)) + >>> y_b[0] = 3 + + Now we are ready to run the solver. + + >>> from scipy.integrate import solve_bvp + >>> res_a = solve_bvp(fun, bc, x, y_a) + >>> res_b = solve_bvp(fun, bc, x, y_b) + + Let's plot the two found solutions. We take an advantage of having the + solution in a spline form to produce a smooth plot. + + >>> x_plot = np.linspace(0, 1, 100) + >>> y_plot_a = res_a.sol(x_plot)[0] + >>> y_plot_b = res_b.sol(x_plot)[0] + >>> import matplotlib.pyplot as plt + >>> plt.plot(x_plot, y_plot_a, label='y_a') + >>> plt.plot(x_plot, y_plot_b, label='y_b') + >>> plt.legend() + >>> plt.xlabel("x") + >>> plt.ylabel("y") + >>> plt.show() + + We see that the two solutions have similar shape, but differ in scale + significantly. + + In the second example, we solve a simple Sturm-Liouville problem:: + + y'' + k**2 * y = 0 + y(0) = y(1) = 0 + + It is known that a non-trivial solution y = A * sin(k * x) is possible for + k = pi * n, where n is an integer. To establish the normalization constant + A = 1 we add a boundary condition:: + + y'(0) = k + + Again, we rewrite our equation as a first-order system and implement its + right-hand side evaluation:: + + y1' = y2 + y2' = -k**2 * y1 + + >>> def fun(x, y, p): + ... k = p[0] + ... return np.vstack((y[1], -k**2 * y[0])) + + Note that parameters p are passed as a vector (with one element in our + case). + + Implement the boundary conditions: + + >>> def bc(ya, yb, p): + ... k = p[0] + ... return np.array([ya[0], yb[0], ya[1] - k]) + + Set up the initial mesh and guess for y. We aim to find the solution for + k = 2 * pi, to achieve that we set values of y to approximately follow + sin(2 * pi * x): + + >>> x = np.linspace(0, 1, 5) + >>> y = np.zeros((2, x.size)) + >>> y[0, 1] = 1 + >>> y[0, 3] = -1 + + Run the solver with 6 as an initial guess for k. + + >>> sol = solve_bvp(fun, bc, x, y, p=[6]) + + We see that the found k is approximately correct: + + >>> sol.p[0] + 6.28329460046 + + And, finally, plot the solution to see the anticipated sinusoid: + + >>> x_plot = np.linspace(0, 1, 100) + >>> y_plot = sol.sol(x_plot)[0] + >>> plt.plot(x_plot, y_plot) + >>> plt.xlabel("x") + >>> plt.ylabel("y") + >>> plt.show() + """ + x = np.asarray(x, dtype=float) + if x.ndim != 1: + raise ValueError("`x` must be 1 dimensional.") + h = np.diff(x) + if np.any(h <= 0): + raise ValueError("`x` must be strictly increasing.") + a = x[0] + + y = np.asarray(y) + if np.issubdtype(y.dtype, np.complexfloating): + dtype = complex + else: + dtype = float + y = y.astype(dtype, copy=False) + + if y.ndim != 2: + raise ValueError("`y` must be 2 dimensional.") + if y.shape[1] != x.shape[0]: + raise ValueError(f"`y` is expected to have {x.shape[0]} columns, but actually " + f"has {y.shape[1]}.") + + if p is None: + p = np.array([]) + else: + p = np.asarray(p, dtype=dtype) + if p.ndim != 1: + raise ValueError("`p` must be 1 dimensional.") + + if tol < 100 * EPS: + warn(f"`tol` is too low, setting to {100 * EPS:.2e}", stacklevel=2) + tol = 100 * EPS + + if verbose not in [0, 1, 2]: + raise ValueError("`verbose` must be in [0, 1, 2].") + + n = y.shape[0] + k = p.shape[0] + + if S is not None: + S = np.asarray(S, dtype=dtype) + if S.shape != (n, n): + raise ValueError(f"`S` is expected to have shape {(n, n)}, " + f"but actually has {S.shape}") + + # Compute I - S^+ S to impose necessary boundary conditions. + B = np.identity(n) - np.dot(pinv(S), S) + + y[:, 0] = np.dot(B, y[:, 0]) + + # Compute (I - S)^+ to correct derivatives at x=a. + D = pinv(np.identity(n) - S) + else: + B = None + D = None + + if bc_tol is None: + bc_tol = tol + + # Maximum number of iterations + max_iteration = 10 + + fun_wrapped, bc_wrapped, fun_jac_wrapped, bc_jac_wrapped = wrap_functions( + fun, bc, fun_jac, bc_jac, k, a, S, D, dtype) + + f = fun_wrapped(x, y, p) + if f.shape != y.shape: + raise ValueError(f"`fun` return is expected to have shape {y.shape}, " + f"but actually has {f.shape}.") + + bc_res = bc_wrapped(y[:, 0], y[:, -1], p) + if bc_res.shape != (n + k,): + raise ValueError(f"`bc` return is expected to have shape {(n + k,)}, " + f"but actually has {bc_res.shape}.") + + status = 0 + iteration = 0 + if verbose == 2: + print_iteration_header() + + while True: + m = x.shape[0] + + col_fun, jac_sys = prepare_sys(n, m, k, fun_wrapped, bc_wrapped, + fun_jac_wrapped, bc_jac_wrapped, x, h) + y, p, singular = solve_newton(n, m, h, col_fun, bc_wrapped, jac_sys, + y, p, B, tol, bc_tol) + iteration += 1 + + col_res, y_middle, f, f_middle = collocation_fun(fun_wrapped, y, + p, x, h) + bc_res = bc_wrapped(y[:, 0], y[:, -1], p) + max_bc_res = np.max(abs(bc_res)) + + # This relation is not trivial, but can be verified. + r_middle = 1.5 * col_res / h + sol = create_spline(y, f, x, h) + rms_res = estimate_rms_residuals(fun_wrapped, sol, x, h, p, + r_middle, f_middle) + max_rms_res = np.max(rms_res) + + if singular: + status = 2 + break + + insert_1, = np.nonzero((rms_res > tol) & (rms_res < 100 * tol)) + insert_2, = np.nonzero(rms_res >= 100 * tol) + nodes_added = insert_1.shape[0] + 2 * insert_2.shape[0] + + if m + nodes_added > max_nodes: + status = 1 + if verbose == 2: + nodes_added = f"({nodes_added})" + print_iteration_progress(iteration, max_rms_res, max_bc_res, + m, nodes_added) + break + + if verbose == 2: + print_iteration_progress(iteration, max_rms_res, max_bc_res, m, + nodes_added) + + if nodes_added > 0: + x = modify_mesh(x, insert_1, insert_2) + h = np.diff(x) + y = sol(x) + elif max_bc_res <= bc_tol: + status = 0 + break + elif iteration >= max_iteration: + status = 3 + break + + if verbose > 0: + if status == 0: + print(f"Solved in {iteration} iterations, number of nodes {x.shape[0]}. \n" + f"Maximum relative residual: {max_rms_res:.2e} \n" + f"Maximum boundary residual: {max_bc_res:.2e}") + elif status == 1: + print(f"Number of nodes is exceeded after iteration {iteration}. \n" + f"Maximum relative residual: {max_rms_res:.2e} \n" + f"Maximum boundary residual: {max_bc_res:.2e}") + elif status == 2: + print("Singular Jacobian encountered when solving the collocation " + f"system on iteration {iteration}. \n" + f"Maximum relative residual: {max_rms_res:.2e} \n" + f"Maximum boundary residual: {max_bc_res:.2e}") + elif status == 3: + print("The solver was unable to satisfy boundary conditions " + f"tolerance on iteration {iteration}. \n" + f"Maximum relative residual: {max_rms_res:.2e} \n" + f"Maximum boundary residual: {max_bc_res:.2e}") + + if p.size == 0: + p = None + + return BVPResult(sol=sol, p=p, x=x, y=y, yp=f, rms_residuals=rms_res, + niter=iteration, status=status, + message=TERMINATION_MESSAGES[status], success=status == 0) diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_lsoda.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_lsoda.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..a8fbd7d95563e4e75a66137410fac5a26c1617a8 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_lsoda.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_test_odeint_banded.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_test_odeint_banded.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..95cd375e0490bec6640cdf39fbcbfb9c34a82424 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_test_odeint_banded.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_vode.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_vode.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..8af33ad79ddfd8a7555d13cfe21c427dc9740b4f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/_vode.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/integrate/dop.py b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/dop.py new file mode 100644 index 0000000000000000000000000000000000000000..5e61e475220e0826a1338a7af327aa3581281728 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/dop.py @@ -0,0 +1,18 @@ +# This file is not meant for public use and will be removed in SciPy v2.0.0. + +from scipy._lib.deprecation import _sub_module_deprecation + +__all__ = [ # noqa: F822 + 'dopri5', + 'dop853' +] + + +def __dir__(): + return __all__ + + +def __getattr__(name): + return _sub_module_deprecation(sub_package="integrate", module="dop", + private_modules=["_dop"], all=__all__, + attribute=name) diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/integrate/lsoda.py b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/lsoda.py new file mode 100644 index 0000000000000000000000000000000000000000..1bc1f1da3c4f0aefad9da73b6405b957ce9335b4 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/lsoda.py @@ -0,0 +1,15 @@ +# This file is not meant for public use and will be removed in SciPy v2.0.0. + +from scipy._lib.deprecation import _sub_module_deprecation + +__all__ = ['lsoda'] # noqa: F822 + + +def __dir__(): + return __all__ + + +def __getattr__(name): + return _sub_module_deprecation(sub_package="integrate", module="lsoda", + private_modules=["_lsoda"], all=__all__, + attribute=name) diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/integrate/odepack.py b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/odepack.py new file mode 100644 index 0000000000000000000000000000000000000000..7bb4c1a8c9be375df855abe6e1b30ca9711f2607 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/scipy/integrate/odepack.py @@ -0,0 +1,17 @@ +# This file is not meant for public use and will be removed in SciPy v2.0.0. +# Use the `scipy.integrate` namespace for importing the functions +# included below. + +from scipy._lib.deprecation import _sub_module_deprecation + +__all__ = ['odeint', 'ODEintWarning'] # noqa: F822 + + +def __dir__(): + return __all__ + + +def __getattr__(name): + return _sub_module_deprecation(sub_package="integrate", module="odepack", + private_modules=["_odepack_py"], all=__all__, + attribute=name) diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/__init__.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6a0a8fbd9ef76c30d495e6a664b30c84dc9d9d72 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/__init__.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_binned_statistic.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_binned_statistic.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4dbb3c1521283f44d13e6bc7413eaeb0220a4965 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_binned_statistic.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_binomtest.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_binomtest.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ba9cc6765b24999b2c1fdec698c5bab573c0eb1d Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_binomtest.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_bws_test.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_bws_test.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2295c5e52d9b223af19b9f019b51afd99fa39fe5 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_bws_test.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_censored_data.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_censored_data.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ac01fc53f00ce45188b0a475437daa3223d5d568 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_censored_data.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_common.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_common.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f246e1bd17711bc7c8f366282078e70375f4b44b Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_common.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_constants.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_constants.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..80c2e4d7b04a7052d8bdf41a0ed8b6c9ed82a6f6 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_constants.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_covariance.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_covariance.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c7d6be4db0ccda0f8396e44b81f5ab51efbbe1e0 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_covariance.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_discrete_distns.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_discrete_distns.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6932a479b702bb06f7b6a98f49365a07e103c161 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_discrete_distns.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_distn_infrastructure.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_distn_infrastructure.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..214ca689e5c900ca9695fa2bbdaa54245ddf1c16 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_distn_infrastructure.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_distr_params.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_distr_params.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..35b00799d288e27877cca5fa8618b5ae4bed247a Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_distr_params.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_entropy.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_entropy.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..56483b5542090b4e349a8934a504b817434f2cd4 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_entropy.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_generate_pyx.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_generate_pyx.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..548a65021d2ee5ba0d97debe710f917727bb12f2 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_generate_pyx.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_hypotests.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_hypotests.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..585f0e74f4d7733f65182055a023969152b54952 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_hypotests.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_kde.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_kde.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..fc5ec4905667de17b93d2cb817d6a3b2910eb96f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_kde.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_ksstats.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_ksstats.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..67f110a5f7afe9eb6bea293cb9bb8f583bd30755 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_ksstats.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mannwhitneyu.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mannwhitneyu.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7f110fb0e60eb0874a5498d0f8cf14d5b5f179ca Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mannwhitneyu.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_morestats.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_morestats.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c62080422bc438115a9263bcd54aca0af06de924 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_morestats.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mstats_basic.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mstats_basic.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b6207e1d6d1d6ea4b8e2ef10173cb82f51838b86 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mstats_basic.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mstats_extras.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mstats_extras.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dea214886d69f78e24ead61f4375317ed6150a4a Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_mstats_extras.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_multicomp.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_multicomp.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d2c1ab8b60ad1628d64f66c3386663b2d37f704f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_multicomp.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_multivariate.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_multivariate.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4215d2d6de419a29ae6ae73e81958a1d47835730 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_multivariate.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_odds_ratio.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_odds_ratio.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..315eaa6c4215d46a1f0a1acf28b59c0f0aa92f98 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_odds_ratio.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_page_trend_test.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_page_trend_test.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9529059e999688468023c36224770b11a1c705e Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_page_trend_test.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_qmc.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_qmc.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bc3655a16998b29a61d9bb91ad7d1a3ef596db8c Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_qmc.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_qmvnt.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_qmvnt.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8b967a32fbfd20e0539a5b3e34f9463e5f033472 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_qmvnt.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_relative_risk.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_relative_risk.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8b76a0a7e8075b933a8fc8d5df4abba284283b29 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_relative_risk.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_resampling.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_resampling.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..762578c38ba670b47c98b4bf179f11de01d5fbc0 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_resampling.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_result_classes.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_result_classes.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1f214518bd4fe52b632b45841ca761152e07b156 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_result_classes.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_rvs_sampling.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_rvs_sampling.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e58b6087f04c4eb1c84d0676f769eb9d51bb5fea Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_rvs_sampling.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_sampling.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_sampling.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bbf4ef4ff8e97da3e5c9aeaf8eacf45478174568 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_sampling.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_sensitivity_analysis.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_sensitivity_analysis.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3076c3b00e04289b91d2117b0aa1927fe1e4a4b5 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_sensitivity_analysis.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_stats_mstats_common.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_stats_mstats_common.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0824f38914f5d76a96b5420ae2f1792212b1482e Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_stats_mstats_common.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_stats_py.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_stats_py.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f18e1dea22847ca11336803dd5d5ef01230d90ff Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_stats_py.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_survival.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_survival.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8e09b319038bf1805d402245d0197d7a2963d417 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_survival.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_tukeylambda_stats.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_tukeylambda_stats.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3015ceb40158185f0fe7fc1af62dc1b977c3c579 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_tukeylambda_stats.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_variation.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_variation.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..76184c835baff9735d9d273179082058e4ba98a1 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_variation.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_warnings_errors.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_warnings_errors.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e20999514498c70e1a6fa1011a3dcaf9b1e9b3be Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_warnings_errors.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_wilcoxon.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_wilcoxon.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..6d5334a3f0045d79e01d6eb9eb4a0428d8ba6d2c Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/_wilcoxon.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/biasedurn.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/biasedurn.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..34c043affe8ce247b35c4fd34041553d48be7ac4 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/biasedurn.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/distributions.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/distributions.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a77472314cea0b9f4993fd7f2949e100e4645448 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/distributions.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/kde.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/kde.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1e86a2fd5031bd5e93e95d1a5b0a924f0bf20640 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/kde.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/morestats.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/morestats.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cba60dfb792c06e303ff43bdee9bdd67d392482e Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/morestats.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f375b6a206b29a538a05d4b6a1cc1848e55893f3 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats_basic.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats_basic.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a32bc4688dfd3d50b37d7183ab90439d77f83753 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats_basic.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats_extras.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats_extras.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..03236fcfc9c8bad6486cfc58b621a6a53c887f96 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mstats_extras.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mvn.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mvn.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c58c4ef9a0dfcc3f7cdd62bcb5432d73b4566554 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/mvn.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/qmc.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/qmc.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a0d34ea0e03f7b88c18a3ac85c4fa627b8408a9a Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/qmc.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/sampling.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/sampling.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..3f136876178f589d19db6f9e7f2e0856b36b186e Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/sampling.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/stats.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/stats.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..19c8094c9c20b71a093a30c15e57a827e1f897f6 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/__pycache__/stats.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/__pycache__/__init__.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/__pycache__/__init__.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..114b4970406326ec967b0b26eb12ab1bd32273d9 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/__pycache__/__init__.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/beta_ufunc.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/beta_ufunc.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..c6fc8abdce1ed48fbaeee945246207ad81718f4d Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/beta_ufunc.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/binom_ufunc.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/binom_ufunc.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..d0829c2805ac1d180b68bc5f404e6397c46ef499 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/binom_ufunc.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/hypergeom_ufunc.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/hypergeom_ufunc.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..bec1f11d81efbd225fedf58f0c65b4fea6580e0b Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/hypergeom_ufunc.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/invgauss_ufunc.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/invgauss_ufunc.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..1598e2cfd2412211079be6328b5544d4ca17d63f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/invgauss_ufunc.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/nbinom_ufunc.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/nbinom_ufunc.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..5e08881cfbdf9a548185c791e3bc057902e8fd83 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/nbinom_ufunc.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/ncf_ufunc.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/ncf_ufunc.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..97edc4cc3a5742b6bd3661d41c9146562dce7e4c Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/ncf_ufunc.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/nct_ufunc.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/nct_ufunc.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..d0dabbae8983dad265c6cec30ee543d0698dc0d4 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/nct_ufunc.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/ncx2_ufunc.cpython-310-x86_64-linux-gnu.so b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/ncx2_ufunc.cpython-310-x86_64-linux-gnu.so new file mode 100644 index 0000000000000000000000000000000000000000..b6b23eef7d8139e4f34b600e5a9d6c4aa23f7b9a Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_boost/ncx2_ufunc.cpython-310-x86_64-linux-gnu.so differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/_levy_stable/__init__.py b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_levy_stable/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..13d143e3dd562e76d75c3517d2d999fcf5640c8f --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/scipy/stats/_levy_stable/__init__.py @@ -0,0 +1,1224 @@ +# + +import warnings +from functools import partial + +import numpy as np + +from scipy import optimize +from scipy import integrate +from scipy.integrate._quadrature import _builtincoeffs +from scipy import interpolate +from scipy.interpolate import RectBivariateSpline +import scipy.special as sc +from scipy._lib._util import _lazywhere +from .._distn_infrastructure import rv_continuous, _ShapeInfo +from .._continuous_distns import uniform, expon, _norm_pdf, _norm_cdf +from .levyst import Nolan +from scipy._lib.doccer import inherit_docstring_from + + +__all__ = ["levy_stable", "levy_stable_gen", "pdf_from_cf_with_fft"] + +# Stable distributions are known for various parameterisations +# some being advantageous for numerical considerations and others +# useful due to their location/scale awareness. +# +# Here we follow [NO] convention (see the references in the docstring +# for levy_stable_gen below). +# +# S0 / Z0 / x0 (aka Zoleterav's M) +# S1 / Z1 / x1 +# +# Where S* denotes parameterisation, Z* denotes standardized +# version where gamma = 1, delta = 0 and x* denotes variable. +# +# Scipy's original Stable was a random variate generator. It +# uses S1 and unfortunately is not a location/scale aware. + + +# default numerical integration tolerance +# used for epsrel in piecewise and both epsrel and epsabs in dni +# (epsabs needed in dni since weighted quad requires epsabs > 0) +_QUAD_EPS = 1.2e-14 + + +def _Phi_Z0(alpha, t): + return ( + -np.tan(np.pi * alpha / 2) * (np.abs(t) ** (1 - alpha) - 1) + if alpha != 1 + else -2.0 * np.log(np.abs(t)) / np.pi + ) + + +def _Phi_Z1(alpha, t): + return ( + np.tan(np.pi * alpha / 2) + if alpha != 1 + else -2.0 * np.log(np.abs(t)) / np.pi + ) + + +def _cf(Phi, t, alpha, beta): + """Characteristic function.""" + return np.exp( + -(np.abs(t) ** alpha) * (1 - 1j * beta * np.sign(t) * Phi(alpha, t)) + ) + + +_cf_Z0 = partial(_cf, _Phi_Z0) +_cf_Z1 = partial(_cf, _Phi_Z1) + + +def _pdf_single_value_cf_integrate(Phi, x, alpha, beta, **kwds): + """To improve DNI accuracy convert characteristic function in to real + valued integral using Euler's formula, then exploit cosine symmetry to + change limits to [0, inf). Finally use cosine addition formula to split + into two parts that can be handled by weighted quad pack. + """ + quad_eps = kwds.get("quad_eps", _QUAD_EPS) + + def integrand1(t): + if t == 0: + return 0 + return np.exp(-(t ** alpha)) * ( + np.cos(beta * (t ** alpha) * Phi(alpha, t)) + ) + + def integrand2(t): + if t == 0: + return 0 + return np.exp(-(t ** alpha)) * ( + np.sin(beta * (t ** alpha) * Phi(alpha, t)) + ) + + with np.errstate(invalid="ignore"): + int1, *ret1 = integrate.quad( + integrand1, + 0, + np.inf, + weight="cos", + wvar=x, + limit=1000, + epsabs=quad_eps, + epsrel=quad_eps, + full_output=1, + ) + + int2, *ret2 = integrate.quad( + integrand2, + 0, + np.inf, + weight="sin", + wvar=x, + limit=1000, + epsabs=quad_eps, + epsrel=quad_eps, + full_output=1, + ) + + return (int1 + int2) / np.pi + + +_pdf_single_value_cf_integrate_Z0 = partial( + _pdf_single_value_cf_integrate, _Phi_Z0 +) +_pdf_single_value_cf_integrate_Z1 = partial( + _pdf_single_value_cf_integrate, _Phi_Z1 +) + + +def _nolan_round_x_near_zeta(x0, alpha, zeta, x_tol_near_zeta): + """Round x close to zeta for Nolan's method in [NO].""" + # "8. When |x0-beta*tan(pi*alpha/2)| is small, the + # computations of the density and cumulative have numerical problems. + # The program works around this by setting + # z = beta*tan(pi*alpha/2) when + # |z-beta*tan(pi*alpha/2)| < tol(5)*alpha**(1/alpha). + # (The bound on the right is ad hoc, to get reasonable behavior + # when alpha is small)." + # where tol(5) = 0.5e-2 by default. + # + # We seem to have partially addressed this through re-expression of + # g(theta) here, but it still needs to be used in some extreme cases. + # Perhaps tol(5) = 0.5e-2 could be reduced for our implementation. + if np.abs(x0 - zeta) < x_tol_near_zeta * alpha ** (1 / alpha): + x0 = zeta + return x0 + + +def _nolan_round_difficult_input( + x0, alpha, beta, zeta, x_tol_near_zeta, alpha_tol_near_one +): + """Round difficult input values for Nolan's method in [NO].""" + + # following Nolan's STABLE, + # "1. When 0 < |alpha-1| < 0.005, the program has numerical problems + # evaluating the pdf and cdf. The current version of the program sets + # alpha=1 in these cases. This approximation is not bad in the S0 + # parameterization." + if np.abs(alpha - 1) < alpha_tol_near_one: + alpha = 1.0 + + # "2. When alpha=1 and |beta| < 0.005, the program has numerical + # problems. The current version sets beta=0." + # We seem to have addressed this through re-expression of g(theta) here + + x0 = _nolan_round_x_near_zeta(x0, alpha, zeta, x_tol_near_zeta) + return x0, alpha, beta + + +def _pdf_single_value_piecewise_Z1(x, alpha, beta, **kwds): + # convert from Nolan's S_1 (aka S) to S_0 (aka Zolaterev M) + # parameterization + + zeta = -beta * np.tan(np.pi * alpha / 2.0) + x0 = x + zeta if alpha != 1 else x + + return _pdf_single_value_piecewise_Z0(x0, alpha, beta, **kwds) + + +def _pdf_single_value_piecewise_Z0(x0, alpha, beta, **kwds): + + quad_eps = kwds.get("quad_eps", _QUAD_EPS) + x_tol_near_zeta = kwds.get("piecewise_x_tol_near_zeta", 0.005) + alpha_tol_near_one = kwds.get("piecewise_alpha_tol_near_one", 0.005) + + zeta = -beta * np.tan(np.pi * alpha / 2.0) + x0, alpha, beta = _nolan_round_difficult_input( + x0, alpha, beta, zeta, x_tol_near_zeta, alpha_tol_near_one + ) + + # some other known distribution pdfs / analytical cases + # TODO: add more where possible with test coverage, + # eg https://en.wikipedia.org/wiki/Stable_distribution#Other_analytic_cases + if alpha == 2.0: + # normal + return _norm_pdf(x0 / np.sqrt(2)) / np.sqrt(2) + elif alpha == 0.5 and beta == 1.0: + # levy + # since S(1/2, 1, gamma, delta; ) == + # S(1/2, 1, gamma, gamma + delta; ). + _x = x0 + 1 + if _x <= 0: + return 0 + + return 1 / np.sqrt(2 * np.pi * _x) / _x * np.exp(-1 / (2 * _x)) + elif alpha == 0.5 and beta == 0.0 and x0 != 0: + # analytical solution [HO] + S, C = sc.fresnel([1 / np.sqrt(2 * np.pi * np.abs(x0))]) + arg = 1 / (4 * np.abs(x0)) + return ( + np.sin(arg) * (0.5 - S[0]) + np.cos(arg) * (0.5 - C[0]) + ) / np.sqrt(2 * np.pi * np.abs(x0) ** 3) + elif alpha == 1.0 and beta == 0.0: + # cauchy + return 1 / (1 + x0 ** 2) / np.pi + + return _pdf_single_value_piecewise_post_rounding_Z0( + x0, alpha, beta, quad_eps, x_tol_near_zeta + ) + + +def _pdf_single_value_piecewise_post_rounding_Z0(x0, alpha, beta, quad_eps, + x_tol_near_zeta): + """Calculate pdf using Nolan's methods as detailed in [NO].""" + + _nolan = Nolan(alpha, beta, x0) + zeta = _nolan.zeta + xi = _nolan.xi + c2 = _nolan.c2 + g = _nolan.g + + # round x0 to zeta again if needed. zeta was recomputed and may have + # changed due to floating point differences. + # See https://github.com/scipy/scipy/pull/18133 + x0 = _nolan_round_x_near_zeta(x0, alpha, zeta, x_tol_near_zeta) + # handle Nolan's initial case logic + if x0 == zeta: + return ( + sc.gamma(1 + 1 / alpha) + * np.cos(xi) + / np.pi + / ((1 + zeta ** 2) ** (1 / alpha / 2)) + ) + elif x0 < zeta: + return _pdf_single_value_piecewise_post_rounding_Z0( + -x0, alpha, -beta, quad_eps, x_tol_near_zeta + ) + + # following Nolan, we may now assume + # x0 > zeta when alpha != 1 + # beta != 0 when alpha == 1 + + # spare calculating integral on null set + # use isclose as macos has fp differences + if np.isclose(-xi, np.pi / 2, rtol=1e-014, atol=1e-014): + return 0.0 + + def integrand(theta): + # limit any numerical issues leading to g_1 < 0 near theta limits + g_1 = g(theta) + if not np.isfinite(g_1) or g_1 < 0: + g_1 = 0 + return g_1 * np.exp(-g_1) + + with np.errstate(all="ignore"): + peak = optimize.bisect( + lambda t: g(t) - 1, -xi, np.pi / 2, xtol=quad_eps + ) + + # this integrand can be very peaked, so we need to force + # QUADPACK to evaluate the function inside its support + # + + # lastly, we add additional samples at + # ~exp(-100), ~exp(-10), ~exp(-5), ~exp(-1) + # to improve QUADPACK's detection of rapidly descending tail behavior + # (this choice is fairly ad hoc) + tail_points = [ + optimize.bisect(lambda t: g(t) - exp_height, -xi, np.pi / 2) + for exp_height in [100, 10, 5] + # exp_height = 1 is handled by peak + ] + intg_points = [0, peak] + tail_points + intg, *ret = integrate.quad( + integrand, + -xi, + np.pi / 2, + points=intg_points, + limit=100, + epsrel=quad_eps, + epsabs=0, + full_output=1, + ) + + return c2 * intg + + +def _cdf_single_value_piecewise_Z1(x, alpha, beta, **kwds): + # convert from Nolan's S_1 (aka S) to S_0 (aka Zolaterev M) + # parameterization + + zeta = -beta * np.tan(np.pi * alpha / 2.0) + x0 = x + zeta if alpha != 1 else x + + return _cdf_single_value_piecewise_Z0(x0, alpha, beta, **kwds) + + +def _cdf_single_value_piecewise_Z0(x0, alpha, beta, **kwds): + + quad_eps = kwds.get("quad_eps", _QUAD_EPS) + x_tol_near_zeta = kwds.get("piecewise_x_tol_near_zeta", 0.005) + alpha_tol_near_one = kwds.get("piecewise_alpha_tol_near_one", 0.005) + + zeta = -beta * np.tan(np.pi * alpha / 2.0) + x0, alpha, beta = _nolan_round_difficult_input( + x0, alpha, beta, zeta, x_tol_near_zeta, alpha_tol_near_one + ) + + # some other known distribution cdfs / analytical cases + # TODO: add more where possible with test coverage, + # eg https://en.wikipedia.org/wiki/Stable_distribution#Other_analytic_cases + if alpha == 2.0: + # normal + return _norm_cdf(x0 / np.sqrt(2)) + elif alpha == 0.5 and beta == 1.0: + # levy + # since S(1/2, 1, gamma, delta; ) == + # S(1/2, 1, gamma, gamma + delta; ). + _x = x0 + 1 + if _x <= 0: + return 0 + + return sc.erfc(np.sqrt(0.5 / _x)) + elif alpha == 1.0 and beta == 0.0: + # cauchy + return 0.5 + np.arctan(x0) / np.pi + + return _cdf_single_value_piecewise_post_rounding_Z0( + x0, alpha, beta, quad_eps, x_tol_near_zeta + ) + + +def _cdf_single_value_piecewise_post_rounding_Z0(x0, alpha, beta, quad_eps, + x_tol_near_zeta): + """Calculate cdf using Nolan's methods as detailed in [NO].""" + _nolan = Nolan(alpha, beta, x0) + zeta = _nolan.zeta + xi = _nolan.xi + c1 = _nolan.c1 + # c2 = _nolan.c2 + c3 = _nolan.c3 + g = _nolan.g + # round x0 to zeta again if needed. zeta was recomputed and may have + # changed due to floating point differences. + # See https://github.com/scipy/scipy/pull/18133 + x0 = _nolan_round_x_near_zeta(x0, alpha, zeta, x_tol_near_zeta) + # handle Nolan's initial case logic + if (alpha == 1 and beta < 0) or x0 < zeta: + # NOTE: Nolan's paper has a typo here! + # He states F(x) = 1 - F(x, alpha, -beta), but this is clearly + # incorrect since F(-infty) would be 1.0 in this case + # Indeed, the alpha != 1, x0 < zeta case is correct here. + return 1 - _cdf_single_value_piecewise_post_rounding_Z0( + -x0, alpha, -beta, quad_eps, x_tol_near_zeta + ) + elif x0 == zeta: + return 0.5 - xi / np.pi + + # following Nolan, we may now assume + # x0 > zeta when alpha != 1 + # beta > 0 when alpha == 1 + + # spare calculating integral on null set + # use isclose as macos has fp differences + if np.isclose(-xi, np.pi / 2, rtol=1e-014, atol=1e-014): + return c1 + + def integrand(theta): + g_1 = g(theta) + return np.exp(-g_1) + + with np.errstate(all="ignore"): + # shrink supports where required + left_support = -xi + right_support = np.pi / 2 + if alpha > 1: + # integrand(t) monotonic 0 to 1 + if integrand(-xi) != 0.0: + res = optimize.minimize( + integrand, + (-xi,), + method="L-BFGS-B", + bounds=[(-xi, np.pi / 2)], + ) + left_support = res.x[0] + else: + # integrand(t) monotonic 1 to 0 + if integrand(np.pi / 2) != 0.0: + res = optimize.minimize( + integrand, + (np.pi / 2,), + method="L-BFGS-B", + bounds=[(-xi, np.pi / 2)], + ) + right_support = res.x[0] + + intg, *ret = integrate.quad( + integrand, + left_support, + right_support, + points=[left_support, right_support], + limit=100, + epsrel=quad_eps, + epsabs=0, + full_output=1, + ) + + return c1 + c3 * intg + + +def _rvs_Z1(alpha, beta, size=None, random_state=None): + """Simulate random variables using Nolan's methods as detailed in [NO]. + """ + + def alpha1func(alpha, beta, TH, aTH, bTH, cosTH, tanTH, W): + return ( + 2 + / np.pi + * ( + (np.pi / 2 + bTH) * tanTH + - beta * np.log((np.pi / 2 * W * cosTH) / (np.pi / 2 + bTH)) + ) + ) + + def beta0func(alpha, beta, TH, aTH, bTH, cosTH, tanTH, W): + return ( + W + / (cosTH / np.tan(aTH) + np.sin(TH)) + * ((np.cos(aTH) + np.sin(aTH) * tanTH) / W) ** (1.0 / alpha) + ) + + def otherwise(alpha, beta, TH, aTH, bTH, cosTH, tanTH, W): + # alpha is not 1 and beta is not 0 + val0 = beta * np.tan(np.pi * alpha / 2) + th0 = np.arctan(val0) / alpha + val3 = W / (cosTH / np.tan(alpha * (th0 + TH)) + np.sin(TH)) + res3 = val3 * ( + ( + np.cos(aTH) + + np.sin(aTH) * tanTH + - val0 * (np.sin(aTH) - np.cos(aTH) * tanTH) + ) + / W + ) ** (1.0 / alpha) + return res3 + + def alphanot1func(alpha, beta, TH, aTH, bTH, cosTH, tanTH, W): + res = _lazywhere( + beta == 0, + (alpha, beta, TH, aTH, bTH, cosTH, tanTH, W), + beta0func, + f2=otherwise, + ) + return res + + alpha = np.broadcast_to(alpha, size) + beta = np.broadcast_to(beta, size) + TH = uniform.rvs( + loc=-np.pi / 2.0, scale=np.pi, size=size, random_state=random_state + ) + W = expon.rvs(size=size, random_state=random_state) + aTH = alpha * TH + bTH = beta * TH + cosTH = np.cos(TH) + tanTH = np.tan(TH) + res = _lazywhere( + alpha == 1, + (alpha, beta, TH, aTH, bTH, cosTH, tanTH, W), + alpha1func, + f2=alphanot1func, + ) + return res + + +def _fitstart_S0(data): + alpha, beta, delta1, gamma = _fitstart_S1(data) + + # Formulas for mapping parameters in S1 parameterization to + # those in S0 parameterization can be found in [NO]. Note that + # only delta changes. + if alpha != 1: + delta0 = delta1 + beta * gamma * np.tan(np.pi * alpha / 2.0) + else: + delta0 = delta1 + 2 * beta * gamma * np.log(gamma) / np.pi + + return alpha, beta, delta0, gamma + + +def _fitstart_S1(data): + # We follow McCullock 1986 method - Simple Consistent Estimators + # of Stable Distribution Parameters + + # fmt: off + # Table III and IV + nu_alpha_range = [2.439, 2.5, 2.6, 2.7, 2.8, 3, 3.2, 3.5, 4, + 5, 6, 8, 10, 15, 25] + nu_beta_range = [0, 0.1, 0.2, 0.3, 0.5, 0.7, 1] + + # table III - alpha = psi_1(nu_alpha, nu_beta) + alpha_table = np.array([ + [2.000, 2.000, 2.000, 2.000, 2.000, 2.000, 2.000], + [1.916, 1.924, 1.924, 1.924, 1.924, 1.924, 1.924], + [1.808, 1.813, 1.829, 1.829, 1.829, 1.829, 1.829], + [1.729, 1.730, 1.737, 1.745, 1.745, 1.745, 1.745], + [1.664, 1.663, 1.663, 1.668, 1.676, 1.676, 1.676], + [1.563, 1.560, 1.553, 1.548, 1.547, 1.547, 1.547], + [1.484, 1.480, 1.471, 1.460, 1.448, 1.438, 1.438], + [1.391, 1.386, 1.378, 1.364, 1.337, 1.318, 1.318], + [1.279, 1.273, 1.266, 1.250, 1.210, 1.184, 1.150], + [1.128, 1.121, 1.114, 1.101, 1.067, 1.027, 0.973], + [1.029, 1.021, 1.014, 1.004, 0.974, 0.935, 0.874], + [0.896, 0.892, 0.884, 0.883, 0.855, 0.823, 0.769], + [0.818, 0.812, 0.806, 0.801, 0.780, 0.756, 0.691], + [0.698, 0.695, 0.692, 0.689, 0.676, 0.656, 0.597], + [0.593, 0.590, 0.588, 0.586, 0.579, 0.563, 0.513]]).T + # transpose because interpolation with `RectBivariateSpline` is with + # `nu_beta` as `x` and `nu_alpha` as `y` + + # table IV - beta = psi_2(nu_alpha, nu_beta) + beta_table = np.array([ + [0, 2.160, 1.000, 1.000, 1.000, 1.000, 1.000], + [0, 1.592, 3.390, 1.000, 1.000, 1.000, 1.000], + [0, 0.759, 1.800, 1.000, 1.000, 1.000, 1.000], + [0, 0.482, 1.048, 1.694, 1.000, 1.000, 1.000], + [0, 0.360, 0.760, 1.232, 2.229, 1.000, 1.000], + [0, 0.253, 0.518, 0.823, 1.575, 1.000, 1.000], + [0, 0.203, 0.410, 0.632, 1.244, 1.906, 1.000], + [0, 0.165, 0.332, 0.499, 0.943, 1.560, 1.000], + [0, 0.136, 0.271, 0.404, 0.689, 1.230, 2.195], + [0, 0.109, 0.216, 0.323, 0.539, 0.827, 1.917], + [0, 0.096, 0.190, 0.284, 0.472, 0.693, 1.759], + [0, 0.082, 0.163, 0.243, 0.412, 0.601, 1.596], + [0, 0.074, 0.147, 0.220, 0.377, 0.546, 1.482], + [0, 0.064, 0.128, 0.191, 0.330, 0.478, 1.362], + [0, 0.056, 0.112, 0.167, 0.285, 0.428, 1.274]]).T + + # Table V and VII + # These are ordered with decreasing `alpha_range`; so we will need to + # reverse them as required by RectBivariateSpline. + alpha_range = [2, 1.9, 1.8, 1.7, 1.6, 1.5, 1.4, 1.3, 1.2, 1.1, + 1, 0.9, 0.8, 0.7, 0.6, 0.5][::-1] + beta_range = [0, 0.25, 0.5, 0.75, 1] + + # Table V - nu_c = psi_3(alpha, beta) + nu_c_table = np.array([ + [1.908, 1.908, 1.908, 1.908, 1.908], + [1.914, 1.915, 1.916, 1.918, 1.921], + [1.921, 1.922, 1.927, 1.936, 1.947], + [1.927, 1.930, 1.943, 1.961, 1.987], + [1.933, 1.940, 1.962, 1.997, 2.043], + [1.939, 1.952, 1.988, 2.045, 2.116], + [1.946, 1.967, 2.022, 2.106, 2.211], + [1.955, 1.984, 2.067, 2.188, 2.333], + [1.965, 2.007, 2.125, 2.294, 2.491], + [1.980, 2.040, 2.205, 2.435, 2.696], + [2.000, 2.085, 2.311, 2.624, 2.973], + [2.040, 2.149, 2.461, 2.886, 3.356], + [2.098, 2.244, 2.676, 3.265, 3.912], + [2.189, 2.392, 3.004, 3.844, 4.775], + [2.337, 2.634, 3.542, 4.808, 6.247], + [2.588, 3.073, 4.534, 6.636, 9.144]])[::-1].T + # transpose because interpolation with `RectBivariateSpline` is with + # `beta` as `x` and `alpha` as `y` + + # Table VII - nu_zeta = psi_5(alpha, beta) + nu_zeta_table = np.array([ + [0, 0.000, 0.000, 0.000, 0.000], + [0, -0.017, -0.032, -0.049, -0.064], + [0, -0.030, -0.061, -0.092, -0.123], + [0, -0.043, -0.088, -0.132, -0.179], + [0, -0.056, -0.111, -0.170, -0.232], + [0, -0.066, -0.134, -0.206, -0.283], + [0, -0.075, -0.154, -0.241, -0.335], + [0, -0.084, -0.173, -0.276, -0.390], + [0, -0.090, -0.192, -0.310, -0.447], + [0, -0.095, -0.208, -0.346, -0.508], + [0, -0.098, -0.223, -0.380, -0.576], + [0, -0.099, -0.237, -0.424, -0.652], + [0, -0.096, -0.250, -0.469, -0.742], + [0, -0.089, -0.262, -0.520, -0.853], + [0, -0.078, -0.272, -0.581, -0.997], + [0, -0.061, -0.279, -0.659, -1.198]])[::-1].T + # fmt: on + + psi_1 = RectBivariateSpline(nu_beta_range, nu_alpha_range, + alpha_table, kx=1, ky=1, s=0) + + def psi_1_1(nu_beta, nu_alpha): + return psi_1(nu_beta, nu_alpha) \ + if nu_beta > 0 else psi_1(-nu_beta, nu_alpha) + + psi_2 = RectBivariateSpline(nu_beta_range, nu_alpha_range, + beta_table, kx=1, ky=1, s=0) + + def psi_2_1(nu_beta, nu_alpha): + return psi_2(nu_beta, nu_alpha) \ + if nu_beta > 0 else -psi_2(-nu_beta, nu_alpha) + + phi_3 = RectBivariateSpline(beta_range, alpha_range, nu_c_table, + kx=1, ky=1, s=0) + + def phi_3_1(beta, alpha): + return phi_3(beta, alpha) if beta > 0 else phi_3(-beta, alpha) + + phi_5 = RectBivariateSpline(beta_range, alpha_range, nu_zeta_table, + kx=1, ky=1, s=0) + + def phi_5_1(beta, alpha): + return phi_5(beta, alpha) if beta > 0 else -phi_5(-beta, alpha) + + # quantiles + p05 = np.percentile(data, 5) + p50 = np.percentile(data, 50) + p95 = np.percentile(data, 95) + p25 = np.percentile(data, 25) + p75 = np.percentile(data, 75) + + nu_alpha = (p95 - p05) / (p75 - p25) + nu_beta = (p95 + p05 - 2 * p50) / (p95 - p05) + + if nu_alpha >= 2.439: + eps = np.finfo(float).eps + alpha = np.clip(psi_1_1(nu_beta, nu_alpha)[0, 0], eps, 2.) + beta = np.clip(psi_2_1(nu_beta, nu_alpha)[0, 0], -1.0, 1.0) + else: + alpha = 2.0 + beta = np.sign(nu_beta) + c = (p75 - p25) / phi_3_1(beta, alpha)[0, 0] + zeta = p50 + c * phi_5_1(beta, alpha)[0, 0] + delta = zeta-beta*c*np.tan(np.pi*alpha/2.) if alpha != 1. else zeta + + return (alpha, beta, delta, c) + + +class levy_stable_gen(rv_continuous): + r"""A Levy-stable continuous random variable. + + %(before_notes)s + + See Also + -------- + levy, levy_l, cauchy, norm + + Notes + ----- + The distribution for `levy_stable` has characteristic function: + + .. math:: + + \varphi(t, \alpha, \beta, c, \mu) = + e^{it\mu -|ct|^{\alpha}(1-i\beta\operatorname{sign}(t)\Phi(\alpha, t))} + + where two different parameterizations are supported. The first :math:`S_1`: + + .. math:: + + \Phi = \begin{cases} + \tan \left({\frac {\pi \alpha }{2}}\right)&\alpha \neq 1\\ + -{\frac {2}{\pi }}\log |t|&\alpha =1 + \end{cases} + + The second :math:`S_0`: + + .. math:: + + \Phi = \begin{cases} + -\tan \left({\frac {\pi \alpha }{2}}\right)(|ct|^{1-\alpha}-1) + &\alpha \neq 1\\ + -{\frac {2}{\pi }}\log |ct|&\alpha =1 + \end{cases} + + + The probability density function for `levy_stable` is: + + .. math:: + + f(x) = \frac{1}{2\pi}\int_{-\infty}^\infty \varphi(t)e^{-ixt}\,dt + + where :math:`-\infty < t < \infty`. This integral does not have a known + closed form. + + `levy_stable` generalizes several distributions. Where possible, they + should be used instead. Specifically, when the shape parameters + assume the values in the table below, the corresponding equivalent + distribution should be used. + + ========= ======== =========== + ``alpha`` ``beta`` Equivalent + ========= ======== =========== + 1/2 -1 `levy_l` + 1/2 1 `levy` + 1 0 `cauchy` + 2 any `norm` (with ``scale=sqrt(2)``) + ========= ======== =========== + + Evaluation of the pdf uses Nolan's piecewise integration approach with the + Zolotarev :math:`M` parameterization by default. There is also the option + to use direct numerical integration of the standard parameterization of the + characteristic function or to evaluate by taking the FFT of the + characteristic function. + + The default method can changed by setting the class variable + ``levy_stable.pdf_default_method`` to one of 'piecewise' for Nolan's + approach, 'dni' for direct numerical integration, or 'fft-simpson' for the + FFT based approach. For the sake of backwards compatibility, the methods + 'best' and 'zolotarev' are equivalent to 'piecewise' and the method + 'quadrature' is equivalent to 'dni'. + + The parameterization can be changed by setting the class variable + ``levy_stable.parameterization`` to either 'S0' or 'S1'. + The default is 'S1'. + + To improve performance of piecewise and direct numerical integration one + can specify ``levy_stable.quad_eps`` (defaults to 1.2e-14). This is used + as both the absolute and relative quadrature tolerance for direct numerical + integration and as the relative quadrature tolerance for the piecewise + method. One can also specify ``levy_stable.piecewise_x_tol_near_zeta`` + (defaults to 0.005) for how close x is to zeta before it is considered the + same as x [NO]. The exact check is + ``abs(x0 - zeta) < piecewise_x_tol_near_zeta*alpha**(1/alpha)``. One can + also specify ``levy_stable.piecewise_alpha_tol_near_one`` (defaults to + 0.005) for how close alpha is to 1 before being considered equal to 1. + + To increase accuracy of FFT calculation one can specify + ``levy_stable.pdf_fft_grid_spacing`` (defaults to 0.001) and + ``pdf_fft_n_points_two_power`` (defaults to None which means a value is + calculated that sufficiently covers the input range). + + Further control over FFT calculation is available by setting + ``pdf_fft_interpolation_degree`` (defaults to 3) for spline order and + ``pdf_fft_interpolation_level`` for determining the number of points to use + in the Newton-Cotes formula when approximating the characteristic function + (considered experimental). + + Evaluation of the cdf uses Nolan's piecewise integration approach with the + Zolatarev :math:`S_0` parameterization by default. There is also the option + to evaluate through integration of an interpolated spline of the pdf + calculated by means of the FFT method. The settings affecting FFT + calculation are the same as for pdf calculation. The default cdf method can + be changed by setting ``levy_stable.cdf_default_method`` to either + 'piecewise' or 'fft-simpson'. For cdf calculations the Zolatarev method is + superior in accuracy, so FFT is disabled by default. + + Fitting estimate uses quantile estimation method in [MC]. MLE estimation of + parameters in fit method uses this quantile estimate initially. Note that + MLE doesn't always converge if using FFT for pdf calculations; this will be + the case if alpha <= 1 where the FFT approach doesn't give good + approximations. + + Any non-missing value for the attribute + ``levy_stable.pdf_fft_min_points_threshold`` will set + ``levy_stable.pdf_default_method`` to 'fft-simpson' if a valid + default method is not otherwise set. + + + + .. warning:: + + For pdf calculations FFT calculation is considered experimental. + + For cdf calculations FFT calculation is considered experimental. Use + Zolatarev's method instead (default). + + The probability density above is defined in the "standardized" form. To + shift and/or scale the distribution use the ``loc`` and ``scale`` + parameters. + Generally ``%(name)s.pdf(x, %(shapes)s, loc, scale)`` is identically + equivalent to ``%(name)s.pdf(y, %(shapes)s) / scale`` with + ``y = (x - loc) / scale``, except in the ``S1`` parameterization if + ``alpha == 1``. In that case ``%(name)s.pdf(x, %(shapes)s, loc, scale)`` + is identically equivalent to ``%(name)s.pdf(y, %(shapes)s) / scale`` with + ``y = (x - loc - 2 * beta * scale * np.log(scale) / np.pi) / scale``. + See [NO2]_ Definition 1.8 for more information. + Note that shifting the location of a distribution + does not make it a "noncentral" distribution. + + References + ---------- + .. [MC] McCulloch, J., 1986. Simple consistent estimators of stable + distribution parameters. Communications in Statistics - Simulation and + Computation 15, 11091136. + .. [WZ] Wang, Li and Zhang, Ji-Hong, 2008. Simpson's rule based FFT method + to compute densities of stable distribution. + .. [NO] Nolan, J., 1997. Numerical Calculation of Stable Densities and + distributions Functions. + .. [NO2] Nolan, J., 2018. Stable Distributions: Models for Heavy Tailed + Data. + .. [HO] Hopcraft, K. I., Jakeman, E., Tanner, R. M. J., 1999. Lévy random + walks with fluctuating step number and multiscale behavior. + + %(example)s + + """ + # Configurable options as class variables + # (accessible from self by attribute lookup). + parameterization = "S1" + pdf_default_method = "piecewise" + cdf_default_method = "piecewise" + quad_eps = _QUAD_EPS + piecewise_x_tol_near_zeta = 0.005 + piecewise_alpha_tol_near_one = 0.005 + pdf_fft_min_points_threshold = None + pdf_fft_grid_spacing = 0.001 + pdf_fft_n_points_two_power = None + pdf_fft_interpolation_level = 3 + pdf_fft_interpolation_degree = 3 + + def _argcheck(self, alpha, beta): + return (alpha > 0) & (alpha <= 2) & (beta <= 1) & (beta >= -1) + + def _shape_info(self): + ialpha = _ShapeInfo("alpha", False, (0, 2), (False, True)) + ibeta = _ShapeInfo("beta", False, (-1, 1), (True, True)) + return [ialpha, ibeta] + + def _parameterization(self): + allowed = ("S0", "S1") + pz = self.parameterization + if pz not in allowed: + raise RuntimeError( + f"Parameterization '{pz}' in supported list: {allowed}" + ) + return pz + + @inherit_docstring_from(rv_continuous) + def rvs(self, *args, **kwds): + X1 = super().rvs(*args, **kwds) + + kwds.pop("discrete", None) + kwds.pop("random_state", None) + (alpha, beta), delta, gamma, size = self._parse_args_rvs(*args, **kwds) + + # shift location for this parameterisation (S1) + X1 = np.where( + alpha == 1.0, X1 + 2 * beta * gamma * np.log(gamma) / np.pi, X1 + ) + + if self._parameterization() == "S0": + return np.where( + alpha == 1.0, + X1 - (beta * 2 * gamma * np.log(gamma) / np.pi), + X1 - gamma * beta * np.tan(np.pi * alpha / 2.0), + ) + elif self._parameterization() == "S1": + return X1 + + def _rvs(self, alpha, beta, size=None, random_state=None): + return _rvs_Z1(alpha, beta, size, random_state) + + @inherit_docstring_from(rv_continuous) + def pdf(self, x, *args, **kwds): + # override base class version to correct + # location for S1 parameterization + if self._parameterization() == "S0": + return super().pdf(x, *args, **kwds) + elif self._parameterization() == "S1": + (alpha, beta), delta, gamma = self._parse_args(*args, **kwds) + if np.all(np.reshape(alpha, (1, -1))[0, :] != 1): + return super().pdf(x, *args, **kwds) + else: + # correct location for this parameterisation + x = np.reshape(x, (1, -1))[0, :] + x, alpha, beta = np.broadcast_arrays(x, alpha, beta) + + data_in = np.dstack((x, alpha, beta))[0] + data_out = np.empty(shape=(len(data_in), 1)) + # group data in unique arrays of alpha, beta pairs + uniq_param_pairs = np.unique(data_in[:, 1:], axis=0) + for pair in uniq_param_pairs: + _alpha, _beta = pair + _delta = ( + delta + 2 * _beta * gamma * np.log(gamma) / np.pi + if _alpha == 1.0 + else delta + ) + data_mask = np.all(data_in[:, 1:] == pair, axis=-1) + _x = data_in[data_mask, 0] + data_out[data_mask] = ( + super() + .pdf(_x, _alpha, _beta, loc=_delta, scale=gamma) + .reshape(len(_x), 1) + ) + output = data_out.T[0] + if output.shape == (1,): + return output[0] + return output + + def _pdf(self, x, alpha, beta): + if self._parameterization() == "S0": + _pdf_single_value_piecewise = _pdf_single_value_piecewise_Z0 + _pdf_single_value_cf_integrate = _pdf_single_value_cf_integrate_Z0 + _cf = _cf_Z0 + elif self._parameterization() == "S1": + _pdf_single_value_piecewise = _pdf_single_value_piecewise_Z1 + _pdf_single_value_cf_integrate = _pdf_single_value_cf_integrate_Z1 + _cf = _cf_Z1 + + x = np.asarray(x).reshape(1, -1)[0, :] + + x, alpha, beta = np.broadcast_arrays(x, alpha, beta) + + data_in = np.dstack((x, alpha, beta))[0] + data_out = np.empty(shape=(len(data_in), 1)) + + pdf_default_method_name = self.pdf_default_method + if pdf_default_method_name in ("piecewise", "best", "zolotarev"): + pdf_single_value_method = _pdf_single_value_piecewise + elif pdf_default_method_name in ("dni", "quadrature"): + pdf_single_value_method = _pdf_single_value_cf_integrate + elif ( + pdf_default_method_name == "fft-simpson" + or self.pdf_fft_min_points_threshold is not None + ): + pdf_single_value_method = None + + pdf_single_value_kwds = { + "quad_eps": self.quad_eps, + "piecewise_x_tol_near_zeta": self.piecewise_x_tol_near_zeta, + "piecewise_alpha_tol_near_one": self.piecewise_alpha_tol_near_one, + } + + fft_grid_spacing = self.pdf_fft_grid_spacing + fft_n_points_two_power = self.pdf_fft_n_points_two_power + fft_interpolation_level = self.pdf_fft_interpolation_level + fft_interpolation_degree = self.pdf_fft_interpolation_degree + + # group data in unique arrays of alpha, beta pairs + uniq_param_pairs = np.unique(data_in[:, 1:], axis=0) + for pair in uniq_param_pairs: + data_mask = np.all(data_in[:, 1:] == pair, axis=-1) + data_subset = data_in[data_mask] + if pdf_single_value_method is not None: + data_out[data_mask] = np.array( + [ + pdf_single_value_method( + _x, _alpha, _beta, **pdf_single_value_kwds + ) + for _x, _alpha, _beta in data_subset + ] + ).reshape(len(data_subset), 1) + else: + warnings.warn( + "Density calculations experimental for FFT method." + + " Use combination of piecewise and dni methods instead.", + RuntimeWarning, stacklevel=3, + ) + _alpha, _beta = pair + _x = data_subset[:, (0,)] + + if _alpha < 1.0: + raise RuntimeError( + "FFT method does not work well for alpha less than 1." + ) + + # need enough points to "cover" _x for interpolation + if fft_grid_spacing is None and fft_n_points_two_power is None: + raise ValueError( + "One of fft_grid_spacing or fft_n_points_two_power " + + "needs to be set." + ) + max_abs_x = np.max(np.abs(_x)) + h = ( + 2 ** (3 - fft_n_points_two_power) * max_abs_x + if fft_grid_spacing is None + else fft_grid_spacing + ) + q = ( + np.ceil(np.log(2 * max_abs_x / h) / np.log(2)) + 2 + if fft_n_points_two_power is None + else int(fft_n_points_two_power) + ) + + # for some parameters, the range of x can be quite + # large, let's choose an arbitrary cut off (8GB) to save on + # computer memory. + MAX_Q = 30 + if q > MAX_Q: + raise RuntimeError( + "fft_n_points_two_power has a maximum " + + f"value of {MAX_Q}" + ) + + density_x, density = pdf_from_cf_with_fft( + lambda t: _cf(t, _alpha, _beta), + h=h, + q=q, + level=fft_interpolation_level, + ) + f = interpolate.InterpolatedUnivariateSpline( + density_x, np.real(density), k=fft_interpolation_degree + ) # patch FFT to use cubic + data_out[data_mask] = f(_x) + + return data_out.T[0] + + @inherit_docstring_from(rv_continuous) + def cdf(self, x, *args, **kwds): + # override base class version to correct + # location for S1 parameterization + # NOTE: this is near identical to pdf() above + if self._parameterization() == "S0": + return super().cdf(x, *args, **kwds) + elif self._parameterization() == "S1": + (alpha, beta), delta, gamma = self._parse_args(*args, **kwds) + if np.all(np.reshape(alpha, (1, -1))[0, :] != 1): + return super().cdf(x, *args, **kwds) + else: + # correct location for this parameterisation + x = np.reshape(x, (1, -1))[0, :] + x, alpha, beta = np.broadcast_arrays(x, alpha, beta) + + data_in = np.dstack((x, alpha, beta))[0] + data_out = np.empty(shape=(len(data_in), 1)) + # group data in unique arrays of alpha, beta pairs + uniq_param_pairs = np.unique(data_in[:, 1:], axis=0) + for pair in uniq_param_pairs: + _alpha, _beta = pair + _delta = ( + delta + 2 * _beta * gamma * np.log(gamma) / np.pi + if _alpha == 1.0 + else delta + ) + data_mask = np.all(data_in[:, 1:] == pair, axis=-1) + _x = data_in[data_mask, 0] + data_out[data_mask] = ( + super() + .cdf(_x, _alpha, _beta, loc=_delta, scale=gamma) + .reshape(len(_x), 1) + ) + output = data_out.T[0] + if output.shape == (1,): + return output[0] + return output + + def _cdf(self, x, alpha, beta): + if self._parameterization() == "S0": + _cdf_single_value_piecewise = _cdf_single_value_piecewise_Z0 + _cf = _cf_Z0 + elif self._parameterization() == "S1": + _cdf_single_value_piecewise = _cdf_single_value_piecewise_Z1 + _cf = _cf_Z1 + + x = np.asarray(x).reshape(1, -1)[0, :] + + x, alpha, beta = np.broadcast_arrays(x, alpha, beta) + + data_in = np.dstack((x, alpha, beta))[0] + data_out = np.empty(shape=(len(data_in), 1)) + + cdf_default_method_name = self.cdf_default_method + if cdf_default_method_name == "piecewise": + cdf_single_value_method = _cdf_single_value_piecewise + elif cdf_default_method_name == "fft-simpson": + cdf_single_value_method = None + + cdf_single_value_kwds = { + "quad_eps": self.quad_eps, + "piecewise_x_tol_near_zeta": self.piecewise_x_tol_near_zeta, + "piecewise_alpha_tol_near_one": self.piecewise_alpha_tol_near_one, + } + + fft_grid_spacing = self.pdf_fft_grid_spacing + fft_n_points_two_power = self.pdf_fft_n_points_two_power + fft_interpolation_level = self.pdf_fft_interpolation_level + fft_interpolation_degree = self.pdf_fft_interpolation_degree + + # group data in unique arrays of alpha, beta pairs + uniq_param_pairs = np.unique(data_in[:, 1:], axis=0) + for pair in uniq_param_pairs: + data_mask = np.all(data_in[:, 1:] == pair, axis=-1) + data_subset = data_in[data_mask] + if cdf_single_value_method is not None: + data_out[data_mask] = np.array( + [ + cdf_single_value_method( + _x, _alpha, _beta, **cdf_single_value_kwds + ) + for _x, _alpha, _beta in data_subset + ] + ).reshape(len(data_subset), 1) + else: + warnings.warn( + "Cumulative density calculations experimental for FFT" + + " method. Use piecewise method instead.", + RuntimeWarning, stacklevel=3, + ) + _alpha, _beta = pair + _x = data_subset[:, (0,)] + + # need enough points to "cover" _x for interpolation + if fft_grid_spacing is None and fft_n_points_two_power is None: + raise ValueError( + "One of fft_grid_spacing or fft_n_points_two_power " + + "needs to be set." + ) + max_abs_x = np.max(np.abs(_x)) + h = ( + 2 ** (3 - fft_n_points_two_power) * max_abs_x + if fft_grid_spacing is None + else fft_grid_spacing + ) + q = ( + np.ceil(np.log(2 * max_abs_x / h) / np.log(2)) + 2 + if fft_n_points_two_power is None + else int(fft_n_points_two_power) + ) + + density_x, density = pdf_from_cf_with_fft( + lambda t: _cf(t, _alpha, _beta), + h=h, + q=q, + level=fft_interpolation_level, + ) + f = interpolate.InterpolatedUnivariateSpline( + density_x, np.real(density), k=fft_interpolation_degree + ) + data_out[data_mask] = np.array( + [f.integral(self.a, float(x_1.squeeze())) for x_1 in _x] + ).reshape(data_out[data_mask].shape) + + return data_out.T[0] + + def _fitstart(self, data): + if self._parameterization() == "S0": + _fitstart = _fitstart_S0 + elif self._parameterization() == "S1": + _fitstart = _fitstart_S1 + return _fitstart(data) + + def _stats(self, alpha, beta): + mu = 0 if alpha > 1 else np.nan + mu2 = 2 if alpha == 2 else np.inf + g1 = 0.0 if alpha == 2.0 else np.nan + g2 = 0.0 if alpha == 2.0 else np.nan + return mu, mu2, g1, g2 + + +# cotes numbers - see sequence from http://oeis.org/A100642 +Cotes_table = np.array( + [[], [1]] + [v[2] for v in _builtincoeffs.values()], dtype=object +) +Cotes = np.array( + [ + np.pad(r, (0, len(Cotes_table) - 1 - len(r)), mode='constant') + for r in Cotes_table + ] +) + + +def pdf_from_cf_with_fft(cf, h=0.01, q=9, level=3): + """Calculates pdf from characteristic function. + + Uses fast Fourier transform with Newton-Cotes integration following [WZ]. + Defaults to using Simpson's method (3-point Newton-Cotes integration). + + Parameters + ---------- + cf : callable + Single argument function from float -> complex expressing a + characteristic function for some distribution. + h : Optional[float] + Step size for Newton-Cotes integration. Default: 0.01 + q : Optional[int] + Use 2**q steps when performing Newton-Cotes integration. + The infinite integral in the inverse Fourier transform will then + be restricted to the interval [-2**q * h / 2, 2**q * h / 2]. Setting + the number of steps equal to a power of 2 allows the fft to be + calculated in O(n*log(n)) time rather than O(n**2). + Default: 9 + level : Optional[int] + Calculate integral using n-point Newton-Cotes integration for + n = level. The 3-point Newton-Cotes formula corresponds to Simpson's + rule. Default: 3 + + Returns + ------- + x_l : ndarray + Array of points x at which pdf is estimated. 2**q equally spaced + points from -pi/h up to but not including pi/h. + density : ndarray + Estimated values of pdf corresponding to cf at points in x_l. + + References + ---------- + .. [WZ] Wang, Li and Zhang, Ji-Hong, 2008. Simpson's rule based FFT method + to compute densities of stable distribution. + """ + n = level + N = 2**q + steps = np.arange(0, N) + L = N * h / 2 + x_l = np.pi * (steps - N / 2) / L + if level > 1: + indices = np.arange(n).reshape(n, 1) + s1 = np.sum( + (-1) ** steps * Cotes[n, indices] * np.fft.fft( + (-1)**steps * cf(-L + h * steps + h * indices / (n - 1)) + ) * np.exp( + 1j * np.pi * indices / (n - 1) + - 2 * 1j * np.pi * indices * steps / + (N * (n - 1)) + ), + axis=0 + ) + else: + s1 = (-1) ** steps * Cotes[n, 0] * np.fft.fft( + (-1) ** steps * cf(-L + h * steps) + ) + density = h * s1 / (2 * np.pi * np.sum(Cotes[n])) + return (x_l, density) + + +levy_stable = levy_stable_gen(name="levy_stable") diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/common_tests.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/common_tests.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0fca6ddff9e2aab510d101b34adf8f1b44b2eaa9 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/common_tests.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_discrete_distns.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_discrete_distns.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..516d4d05a952017356dd51f6ef54459c4eabfd4f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_discrete_distns.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_distributions.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_distributions.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..4dbd2a94f57f27cdd66c7b516a2ef6181edf9df5 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_distributions.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_multicomp.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_multicomp.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bcbaf254a6ed65fcd1e070455e14cb5fe802d07f Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_multicomp.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_odds_ratio.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_odds_ratio.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..84ca4c1a0d0bb4a793888f79da97c28333769af7 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_odds_ratio.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_relative_risk.cpython-310.pyc b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_relative_risk.cpython-310.pyc new file mode 100644 index 0000000000000000000000000000000000000000..1ce8bafdec9c60a1e91142724fe241ba560c4fe3 Binary files /dev/null and b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/__pycache__/test_relative_risk.cpython-310.pyc differ diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/data/_mvt.py b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/data/_mvt.py new file mode 100644 index 0000000000000000000000000000000000000000..c346d0daded4b6e734718742cc8950b84ed333f7 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/data/_mvt.py @@ -0,0 +1,171 @@ +import math +import numpy as np +from scipy import special +from scipy.stats._qmc import primes_from_2_to + + +def _primes(n): + # Defined to facilitate comparison between translation and source + # In Matlab, primes(10.5) -> first four primes, primes(11.5) -> first five + return primes_from_2_to(math.ceil(n)) + + +def _gaminv(a, b): + # Defined to facilitate comparison between translation and source + # Matlab's `gaminv` is like `special.gammaincinv` but args are reversed + return special.gammaincinv(b, a) + + +def _qsimvtv(m, nu, sigma, a, b, rng): + """Estimates the multivariate t CDF using randomized QMC + + Parameters + ---------- + m : int + The number of points + nu : float + Degrees of freedom + sigma : ndarray + A 2D positive semidefinite covariance matrix + a : ndarray + Lower integration limits + b : ndarray + Upper integration limits. + rng : Generator + Pseudorandom number generator + + Returns + ------- + p : float + The estimated CDF. + e : float + An absolute error estimate. + + """ + # _qsimvtv is a Python translation of the Matlab function qsimvtv, + # semicolons and all. + # + # This function uses an algorithm given in the paper + # "Comparison of Methods for the Numerical Computation of + # Multivariate t Probabilities", in + # J. of Computational and Graphical Stat., 11(2002), pp. 950-971, by + # Alan Genz and Frank Bretz + # + # The primary references for the numerical integration are + # "On a Number-Theoretical Integration Method" + # H. Niederreiter, Aequationes Mathematicae, 8(1972), pp. 304-11. + # and + # "Randomization of Number Theoretic Methods for Multiple Integration" + # R. Cranley & T.N.L. Patterson, SIAM J Numer Anal, 13(1976), pp. 904-14. + # + # Alan Genz is the author of this function and following Matlab functions. + # Alan Genz, WSU Math, PO Box 643113, Pullman, WA 99164-3113 + # Email : alangenz@wsu.edu + # + # Copyright (C) 2013, Alan Genz, All rights reserved. + # + # Redistribution and use in source and binary forms, with or without + # modification, are permitted provided the following conditions are met: + # 1. Redistributions of source code must retain the above copyright + # notice, this list of conditions and the following disclaimer. + # 2. Redistributions in binary form must reproduce the above copyright + # notice, this list of conditions and the following disclaimer in + # the documentation and/or other materials provided with the + # distribution. + # 3. The contributor name(s) may not be used to endorse or promote + # products derived from this software without specific prior + # written permission. + # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR + # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF USE + # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + # Initialization + sn = max(1, math.sqrt(nu)); ch, az, bz = _chlrps(sigma, a/sn, b/sn) + n = len(sigma); N = 10; P = math.ceil(m/N); on = np.ones(P); p = 0; e = 0 + ps = np.sqrt(_primes(5*n*math.log(n+4)/4)); q = ps[:, np.newaxis] # Richtmyer gens. + + # Randomization loop for ns samples + c = None; dc = None + for S in range(N): + vp = on.copy(); s = np.zeros((n, P)) + for i in range(n): + x = np.abs(2*np.mod(q[i]*np.arange(1, P+1) + rng.random(), 1)-1) # periodizing transform + if i == 0: + r = on + if nu > 0: + r = np.sqrt(2*_gaminv(x, nu/2)) + else: + y = _Phinv(c + x*dc) + s[i:] += ch[i:, i-1:i] * y + si = s[i, :]; c = on.copy(); ai = az[i]*r - si; d = on.copy(); bi = bz[i]*r - si + c[ai <= -9] = 0; tl = abs(ai) < 9; c[tl] = _Phi(ai[tl]) + d[bi <= -9] = 0; tl = abs(bi) < 9; d[tl] = _Phi(bi[tl]) + dc = d - c; vp = vp * dc + d = (np.mean(vp) - p)/(S + 1); p = p + d; e = (S - 1)*e/(S + 1) + d**2 + e = math.sqrt(e) # error estimate is 3 times std error with N samples. + return p, e + + +# Standard statistical normal distribution functions +def _Phi(z): + return special.ndtr(z) + + +def _Phinv(p): + return special.ndtri(p) + + +def _chlrps(R, a, b): + """ + Computes permuted and scaled lower Cholesky factor c for R which may be + singular, also permuting and scaling integration limit vectors a and b. + """ + ep = 1e-10 # singularity tolerance + eps = np.finfo(R.dtype).eps + + n = len(R); c = R.copy(); ap = a.copy(); bp = b.copy(); d = np.sqrt(np.maximum(np.diag(c), 0)) + for i in range(n): + if d[i] > 0: + c[:, i] /= d[i]; c[i, :] /= d[i] + ap[i] /= d[i]; bp[i] /= d[i] + y = np.zeros((n, 1)); sqtp = math.sqrt(2*math.pi) + + for k in range(n): + im = k; ckk = 0; dem = 1; s = 0 + for i in range(k, n): + if c[i, i] > eps: + cii = math.sqrt(max(c[i, i], 0)) + if i > 0: s = c[i, :k] @ y[:k] + ai = (ap[i]-s)/cii; bi = (bp[i]-s)/cii; de = _Phi(bi)-_Phi(ai) + if de <= dem: + ckk = cii; dem = de; am = ai; bm = bi; im = i + if im > k: + ap[[im, k]] = ap[[k, im]]; bp[[im, k]] = bp[[k, im]]; c[im, im] = c[k, k] + t = c[im, :k].copy(); c[im, :k] = c[k, :k]; c[k, :k] = t + t = c[im+1:, im].copy(); c[im+1:, im] = c[im+1:, k]; c[im+1:, k] = t + t = c[k+1:im, k].copy(); c[k+1:im, k] = c[im, k+1:im].T; c[im, k+1:im] = t.T + if ckk > ep*(k+1): + c[k, k] = ckk; c[k, k+1:] = 0 + for i in range(k+1, n): + c[i, k] = c[i, k]/ckk; c[i, k+1:i+1] = c[i, k+1:i+1] - c[i, k]*c[k+1:i+1, k].T + if abs(dem) > ep: + y[k] = (np.exp(-am**2/2) - np.exp(-bm**2/2)) / (sqtp*dem) + else: + y[k] = (am + bm) / 2 + if am < -10: + y[k] = bm + elif bm > 10: + y[k] = am + c[k, :k+1] /= ckk; ap[k] /= ckk; bp[k] /= ckk + else: + c[k:, k] = 0; y[k] = (ap[k] + bp[k])/2 + pass + return c, ap, bp diff --git a/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/data/fisher_exact_results_from_r.py b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/data/fisher_exact_results_from_r.py new file mode 100644 index 0000000000000000000000000000000000000000..b7dd8936018eae2f74cc6f5966235a86fa821793 --- /dev/null +++ b/llmeval-env/lib/python3.10/site-packages/scipy/stats/tests/data/fisher_exact_results_from_r.py @@ -0,0 +1,607 @@ +# DO NOT EDIT THIS FILE! +# This file was generated by the R script +# generate_fisher_exact_results_from_r.R +# The script was run with R version 3.6.2 (2019-12-12) at 2020-11-09 06:16:09 + + +from collections import namedtuple +import numpy as np + + +Inf = np.inf + +Parameters = namedtuple('Parameters', + ['table', 'confidence_level', 'alternative']) +RResults = namedtuple('RResults', + ['pvalue', 'conditional_odds_ratio', + 'conditional_odds_ratio_ci']) +data = [ + (Parameters(table=[[100, 2], [1000, 5]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.1300759363430016, + conditional_odds_ratio=0.25055839934223, + conditional_odds_ratio_ci=(0.04035202926536294, + 2.662846672960251))), + (Parameters(table=[[2, 7], [8, 2]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.02301413756522116, + conditional_odds_ratio=0.0858623513573622, + conditional_odds_ratio_ci=(0.004668988338943325, + 0.895792956493601))), + (Parameters(table=[[5, 1], [10, 10]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.1973244147157191, + conditional_odds_ratio=4.725646047336587, + conditional_odds_ratio_ci=(0.4153910882532168, + 259.2593661129417))), + (Parameters(table=[[5, 15], [20, 20]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.09580440012477633, + conditional_odds_ratio=0.3394396617440851, + conditional_odds_ratio_ci=(0.08056337526385809, + 1.22704788545557))), + (Parameters(table=[[5, 16], [16, 25]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.2697004098849359, + conditional_odds_ratio=0.4937791394540491, + conditional_odds_ratio_ci=(0.1176691231650079, + 1.787463657995973))), + (Parameters(table=[[10, 5], [10, 1]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.1973244147157192, + conditional_odds_ratio=0.2116112781158479, + conditional_odds_ratio_ci=(0.003857141267422399, + 2.407369893767229))), + (Parameters(table=[[10, 5], [10, 0]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.06126482213438735, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 1.451643573543705))), + (Parameters(table=[[5, 0], [1, 4]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.04761904761904762, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(1.024822256141754, + Inf))), + (Parameters(table=[[0, 5], [1, 4]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 39.00054996869288))), + (Parameters(table=[[5, 1], [0, 4]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.04761904761904761, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(1.024822256141754, + Inf))), + (Parameters(table=[[0, 1], [3, 2]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 39.00054996869287))), + (Parameters(table=[[200, 7], [8, 300]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=2.005657880389071e-122, + conditional_odds_ratio=977.7866978606228, + conditional_odds_ratio_ci=(349.2595113327733, + 3630.382605689872))), + (Parameters(table=[[28, 21], [6, 1957]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=5.728437460831947e-44, + conditional_odds_ratio=425.2403028434684, + conditional_odds_ratio_ci=(152.4166024390096, + 1425.700792178893))), + (Parameters(table=[[190, 800], [200, 900]], + confidence_level=0.95, + alternative='two.sided'), + RResults(pvalue=0.574111858126088, + conditional_odds_ratio=1.068697577856801, + conditional_odds_ratio_ci=(0.8520462587912048, + 1.340148950273938))), + (Parameters(table=[[100, 2], [1000, 5]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.1300759363430016, + conditional_odds_ratio=0.25055839934223, + conditional_odds_ratio_ci=(0.02502345007115455, + 6.304424772117853))), + (Parameters(table=[[2, 7], [8, 2]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.02301413756522116, + conditional_odds_ratio=0.0858623513573622, + conditional_odds_ratio_ci=(0.001923034001462487, + 1.53670836950172))), + (Parameters(table=[[5, 1], [10, 10]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.1973244147157191, + conditional_odds_ratio=4.725646047336587, + conditional_odds_ratio_ci=(0.2397970951413721, + 1291.342011095509))), + (Parameters(table=[[5, 15], [20, 20]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.09580440012477633, + conditional_odds_ratio=0.3394396617440851, + conditional_odds_ratio_ci=(0.05127576113762925, + 1.717176678806983))), + (Parameters(table=[[5, 16], [16, 25]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.2697004098849359, + conditional_odds_ratio=0.4937791394540491, + conditional_odds_ratio_ci=(0.07498546954483619, + 2.506969905199901))), + (Parameters(table=[[10, 5], [10, 1]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.1973244147157192, + conditional_odds_ratio=0.2116112781158479, + conditional_odds_ratio_ci=(0.0007743881879531337, + 4.170192301163831))), + (Parameters(table=[[10, 5], [10, 0]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.06126482213438735, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 2.642491011905582))), + (Parameters(table=[[5, 0], [1, 4]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.04761904761904762, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(0.496935393325443, + Inf))), + (Parameters(table=[[0, 5], [1, 4]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 198.019801980198))), + (Parameters(table=[[5, 1], [0, 4]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.04761904761904761, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(0.496935393325443, + Inf))), + (Parameters(table=[[0, 1], [3, 2]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 198.019801980198))), + (Parameters(table=[[200, 7], [8, 300]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=2.005657880389071e-122, + conditional_odds_ratio=977.7866978606228, + conditional_odds_ratio_ci=(270.0334165523604, + 5461.333333326708))), + (Parameters(table=[[28, 21], [6, 1957]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=5.728437460831947e-44, + conditional_odds_ratio=425.2403028434684, + conditional_odds_ratio_ci=(116.7944750275836, + 1931.995993191814))), + (Parameters(table=[[190, 800], [200, 900]], + confidence_level=0.99, + alternative='two.sided'), + RResults(pvalue=0.574111858126088, + conditional_odds_ratio=1.068697577856801, + conditional_odds_ratio_ci=(0.7949398282935892, + 1.436229679394333))), + (Parameters(table=[[100, 2], [1000, 5]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.1300759363430016, + conditional_odds_ratio=0.25055839934223, + conditional_odds_ratio_ci=(0, + 1.797867027270803))), + (Parameters(table=[[2, 7], [8, 2]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.0185217259520665, + conditional_odds_ratio=0.0858623513573622, + conditional_odds_ratio_ci=(0, + 0.6785254803404526))), + (Parameters(table=[[5, 1], [10, 10]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.9782608695652173, + conditional_odds_ratio=4.725646047336587, + conditional_odds_ratio_ci=(0, + 127.8497388102893))), + (Parameters(table=[[5, 15], [20, 20]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.05625775074399956, + conditional_odds_ratio=0.3394396617440851, + conditional_odds_ratio_ci=(0, + 1.032332939718425))), + (Parameters(table=[[5, 16], [16, 25]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.1808979350599346, + conditional_odds_ratio=0.4937791394540491, + conditional_odds_ratio_ci=(0, + 1.502407513296985))), + (Parameters(table=[[10, 5], [10, 1]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.1652173913043479, + conditional_odds_ratio=0.2116112781158479, + conditional_odds_ratio_ci=(0, + 1.820421051562392))), + (Parameters(table=[[10, 5], [10, 0]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.0565217391304348, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 1.06224603077045))), + (Parameters(table=[[5, 0], [1, 4]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=1, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[0, 5], [1, 4]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.5, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 19.00192394479939))), + (Parameters(table=[[5, 1], [0, 4]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=1, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[0, 1], [3, 2]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.4999999999999999, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 19.00192394479939))), + (Parameters(table=[[200, 7], [8, 300]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=1, + conditional_odds_ratio=977.7866978606228, + conditional_odds_ratio_ci=(0, + 3045.460216525746))), + (Parameters(table=[[28, 21], [6, 1957]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=1, + conditional_odds_ratio=425.2403028434684, + conditional_odds_ratio_ci=(0, + 1186.440170942579))), + (Parameters(table=[[190, 800], [200, 900]], + confidence_level=0.95, + alternative='less'), + RResults(pvalue=0.7416227010368963, + conditional_odds_ratio=1.068697577856801, + conditional_odds_ratio_ci=(0, + 1.293551891610822))), + (Parameters(table=[[100, 2], [1000, 5]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.1300759363430016, + conditional_odds_ratio=0.25055839934223, + conditional_odds_ratio_ci=(0, + 4.375946050832565))), + (Parameters(table=[[2, 7], [8, 2]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.0185217259520665, + conditional_odds_ratio=0.0858623513573622, + conditional_odds_ratio_ci=(0, + 1.235282118191202))), + (Parameters(table=[[5, 1], [10, 10]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.9782608695652173, + conditional_odds_ratio=4.725646047336587, + conditional_odds_ratio_ci=(0, + 657.2063583945989))), + (Parameters(table=[[5, 15], [20, 20]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.05625775074399956, + conditional_odds_ratio=0.3394396617440851, + conditional_odds_ratio_ci=(0, + 1.498867660683128))), + (Parameters(table=[[5, 16], [16, 25]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.1808979350599346, + conditional_odds_ratio=0.4937791394540491, + conditional_odds_ratio_ci=(0, + 2.186159386716762))), + (Parameters(table=[[10, 5], [10, 1]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.1652173913043479, + conditional_odds_ratio=0.2116112781158479, + conditional_odds_ratio_ci=(0, + 3.335351451901569))), + (Parameters(table=[[10, 5], [10, 0]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.0565217391304348, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 2.075407697450433))), + (Parameters(table=[[5, 0], [1, 4]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=1, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[0, 5], [1, 4]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.5, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 99.00009507969122))), + (Parameters(table=[[5, 1], [0, 4]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=1, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[0, 1], [3, 2]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.4999999999999999, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + 99.00009507969123))), + (Parameters(table=[[200, 7], [8, 300]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=1, + conditional_odds_ratio=977.7866978606228, + conditional_odds_ratio_ci=(0, + 4503.078257659934))), + (Parameters(table=[[28, 21], [6, 1957]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=1, + conditional_odds_ratio=425.2403028434684, + conditional_odds_ratio_ci=(0, + 1811.766127544222))), + (Parameters(table=[[190, 800], [200, 900]], + confidence_level=0.99, + alternative='less'), + RResults(pvalue=0.7416227010368963, + conditional_odds_ratio=1.068697577856801, + conditional_odds_ratio_ci=(0, + 1.396522811516685))), + (Parameters(table=[[100, 2], [1000, 5]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.979790445314723, + conditional_odds_ratio=0.25055839934223, + conditional_odds_ratio_ci=(0.05119649909830196, + Inf))), + (Parameters(table=[[2, 7], [8, 2]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.9990149169715733, + conditional_odds_ratio=0.0858623513573622, + conditional_odds_ratio_ci=(0.007163749169069961, + Inf))), + (Parameters(table=[[5, 1], [10, 10]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.1652173913043478, + conditional_odds_ratio=4.725646047336587, + conditional_odds_ratio_ci=(0.5493234651081089, + Inf))), + (Parameters(table=[[5, 15], [20, 20]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.9849086665340765, + conditional_odds_ratio=0.3394396617440851, + conditional_odds_ratio_ci=(0.1003538933958604, + Inf))), + (Parameters(table=[[5, 16], [16, 25]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.9330176609214881, + conditional_odds_ratio=0.4937791394540491, + conditional_odds_ratio_ci=(0.146507416280863, + Inf))), + (Parameters(table=[[10, 5], [10, 1]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.9782608695652174, + conditional_odds_ratio=0.2116112781158479, + conditional_odds_ratio_ci=(0.007821681994077808, + Inf))), + (Parameters(table=[[10, 5], [10, 0]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[5, 0], [1, 4]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.02380952380952382, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(1.487678929918272, + Inf))), + (Parameters(table=[[0, 5], [1, 4]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[5, 1], [0, 4]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.0238095238095238, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(1.487678929918272, + Inf))), + (Parameters(table=[[0, 1], [3, 2]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[200, 7], [8, 300]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=2.005657880388915e-122, + conditional_odds_ratio=977.7866978606228, + conditional_odds_ratio_ci=(397.784359748113, + Inf))), + (Parameters(table=[[28, 21], [6, 1957]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=5.728437460831983e-44, + conditional_odds_ratio=425.2403028434684, + conditional_odds_ratio_ci=(174.7148056880929, + Inf))), + (Parameters(table=[[190, 800], [200, 900]], + confidence_level=0.95, + alternative='greater'), + RResults(pvalue=0.2959825901308897, + conditional_odds_ratio=1.068697577856801, + conditional_odds_ratio_ci=(0.8828406663967776, + Inf))), + (Parameters(table=[[100, 2], [1000, 5]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.979790445314723, + conditional_odds_ratio=0.25055839934223, + conditional_odds_ratio_ci=(0.03045407081240429, + Inf))), + (Parameters(table=[[2, 7], [8, 2]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.9990149169715733, + conditional_odds_ratio=0.0858623513573622, + conditional_odds_ratio_ci=(0.002768053063547901, + Inf))), + (Parameters(table=[[5, 1], [10, 10]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.1652173913043478, + conditional_odds_ratio=4.725646047336587, + conditional_odds_ratio_ci=(0.2998184792279909, + Inf))), + (Parameters(table=[[5, 15], [20, 20]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.9849086665340765, + conditional_odds_ratio=0.3394396617440851, + conditional_odds_ratio_ci=(0.06180414342643172, + Inf))), + (Parameters(table=[[5, 16], [16, 25]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.9330176609214881, + conditional_odds_ratio=0.4937791394540491, + conditional_odds_ratio_ci=(0.09037094010066403, + Inf))), + (Parameters(table=[[10, 5], [10, 1]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.9782608695652174, + conditional_odds_ratio=0.2116112781158479, + conditional_odds_ratio_ci=(0.001521592095430679, + Inf))), + (Parameters(table=[[10, 5], [10, 0]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[5, 0], [1, 4]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.02380952380952382, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(0.6661157890359722, + Inf))), + (Parameters(table=[[0, 5], [1, 4]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[5, 1], [0, 4]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.0238095238095238, + conditional_odds_ratio=Inf, + conditional_odds_ratio_ci=(0.6661157890359725, + Inf))), + (Parameters(table=[[0, 1], [3, 2]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=1, + conditional_odds_ratio=0, + conditional_odds_ratio_ci=(0, + Inf))), + (Parameters(table=[[200, 7], [8, 300]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=2.005657880388915e-122, + conditional_odds_ratio=977.7866978606228, + conditional_odds_ratio_ci=(297.9619252357688, + Inf))), + (Parameters(table=[[28, 21], [6, 1957]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=5.728437460831983e-44, + conditional_odds_ratio=425.2403028434684, + conditional_odds_ratio_ci=(130.3213490295859, + Inf))), + (Parameters(table=[[190, 800], [200, 900]], + confidence_level=0.99, + alternative='greater'), + RResults(pvalue=0.2959825901308897, + conditional_odds_ratio=1.068697577856801, + conditional_odds_ratio_ci=(0.8176272148267533, + Inf))), +]