Dear SymPy Developers Group,
I hope this email finds you well. I am currently exploring the use of SymPy, a powerful symbolic mathematics library, to simplify equations related to mathematical statistics. Specifically, I am interested in developing a function that can handle statistical equations by recognizing and substituting large sample size (asymptotic) approximations.
Here are the key aspects I’d like to address:
In summary, my goal is to input formulas that involve distributions (such as binomial and Poisson distributions) into SymPy. The library should then simplify these formulas using well-known large sample size approximations, including the normal distribution and Sterling’s approximation. For example, if the ratio of a Poisson Distribution divided by a Binomial Distribution is input, it should output a mathematically simplified expression representing the large sample size approximations of the Poisson distribution divided by the large sample size approximation for the Binomial distribution.
If there are existing methods or tools for achieving this, I would greatly appreciate any guidance or pointers. Alternatively, if no such methods currently exist, I am enthusiastic about contributing to the development of this functionality.
Thank you for your time, and I look forward to any insights or suggestions you may have.
Best regards,
Matthew Robinson
Hi everyone,
I’m encountering an issue with the last line of my code and could use some help troubleshooting it. I suspect that the SymPy Stats module might be adding unknown attributes to a variable, which is causing the problem.
Any insights or suggestions would be greatly appreciated!
Thank you,
Matthew Robinson
##### Start of Code #####
#This code derives the distribution of a Bray-Curtis Dissimilarity
from sympy import * #Import the SymPy module
from sympy.stats import *
rate1 = Symbol("rate1", positive=True) #Define parameter lambda_1 as positive
rate2 = Symbol("rate2", positive=True) #Define parameter lambda_2 as positive
Y1 = Poisson("y1", rate1) #Make parameter lambda_1 Poisson Distribution function
Y2 = Poisson("y2", rate2) #Make parameter lambda_2 Poisson Distribution function
min_density_Y1 = 2*density(Y1)(rate1) - 2*density(Y1)(rate1)*cdf(Y1)(rate1)
min_density_Y2 = 2*density(Y2)(rate2) - 2*density(Y2)(rate2)*cdf(Y2)(rate2)
Bray_Curtis_Density = 1 - 2 * (min_density_Y1 + min_density_Y2) / (Y1 + Y2)
Bray_Curtis_Density #Print Results
#Export to SciPy for numerical evaluation
export_fcn = lambdify([rate1, rate2], Bray_Curtis_Density)
result = export_fcn(5, 10) #The distriubtion for the given rate parameters
print(result)
## Why is the line below failing?? Why isn’t the variable ‘y1’ in the locals() ?? Please help
result(y1 = 6, y2 = 9)