问题
I have 5 arrays (columns of a pandas data frame) and I want calculate the best fit for a linear combination of the distributions to an exponential distribution. for example:
a*(d1)+b*(d2)+c*(d3)+d*(d4)+e*(d5)=Y
where Y has an exponential distribution (which i know) and a,b,c,d,e are the coefficients to fit.
I tried using curve_fit or lmfit python libraries but didn't get how to do it effectively.
回答1:
What you're describing is a linear model. Use the package scikit-learn:
from sklearn.linear_model import LinearRegression
X = df[['d1', 'd2', 'd3', 'd4', 'd5']]
reg = LinearRegression().fit(X, Y)
reg.get_params()
来源:https://stackoverflow.com/questions/61878031/fitting-a-linear-combination-of-distributions