data-fitting

How to fit a negative binomial, normal, and poisson density function on the same ggplot2 (R) but scaled to the count data?

夙愿已清 提交于 2020-05-27 06:04:13
问题 I have some count data. I want to plot histogram with the count data and add the negative binomial, normal, and Poisson density function but fit the functions to the count data. I tried following this example but (a) I have trouble fitting the negative binomial and poisson functions (b) No where close to scaling it to the count data level (c) Dont know how to fit all three on same graph with legends for each line (d) Also, how can I get basic stats of each fit? for example, the neg binomial

Fit a 3D line to 3D point data in Java?

久未见 提交于 2020-01-21 06:53:54
问题 I've spent a decent amount of time trying to hunt down a simple way of doing this - ideally, a magical library exists out there somewhere that will take my set of 3D data points and return 2 points on the best fit line using either orthogonal regression or least squares and also return the error of the fitted line. Does such a thing exist, and if so, where? 回答1: This is easy enough to do, but to write it yourself you will need an eigenvalue solver or a singular value decomposition. Create the

Fitting a 2D Gaussian to 2D Data Matlab

萝らか妹 提交于 2020-01-16 12:28:41
问题 I have a vector of x and y coordinates drawn from two separate unknown Gaussian distributions. I would like to fit these points to a three dimensional Gauss function and evaluate this function at any x and y . So far the only manner I've found of doing this is using a Gaussian Mixture model with a maximum of 1 component (see code below) and going into the handle of ezcontour to take the X, Y, and Z data out. The problems with this method is firstly that its a very ugly roundabout manner of

Wrong fit with error bars in Gnuplot

偶尔善良 提交于 2020-01-15 04:57:31
问题 Fitting without errors (works) I made a simple linear fit in Gnuplot 5.0 using the command: f(x)=a*x+b fit f(x) 'file.dat' using 1:2 via a,b I get the output: degrees of freedom (FIT_NDF) : 6 rms of residuals (FIT_STDFIT) = sqrt(WSSR/ndf) : 0.00794747 variance of residuals (reduced chisquare) = WSSR/ndf : 6.31623e-05 Final set of parameters Asymptotic Standard Error ======================= ========================== p1 = -0.00964423 +/- 0.0004976 (5.159%) p2 = 1.07794 +/- 0.01908 (1.77%) The

Matplotlib- plot piecewise Linear Function with three parts

空扰寡人 提交于 2020-01-15 03:27:49
问题 I have some data that I want to fit with a piecewise linear function that has three parts. So something like this if there were two inflection points: Unfortunately, when I use the following code, I do not get the correct data, it instead looks like this Anyone know what's wrong? Thanks! def piecewise_linear2(x, x0, y0, k1, k2, k3): return np.piecewise(x, [x < x0], [lambda x:k1*x + y0-k1*x0, lambda x:k2*x + y0-k2*x0, lambda x:k3*x + y0-k3*x0]) fit_days = np.array([1786,1852,2067,2142,2143

Fitting a sum to data in Python

谁都会走 提交于 2020-01-13 04:44:34
问题 Given that the fitting function is of type: I intend to fit such function to the experimental data (x,y=f(x)) that I have. But then I have some doubts: How do I define my fitting function when there's a summation involved? Once the function defined, i.e. def func(..) return ... is it still possible to use curve_fit from scipy.optimize? Because now there's a set of parameters s_i and r_i involved compared to the usual fitting cases where one has few single parameters. Finally are such cases

SciPy LeastSq Goodness of Fit Estimator

帅比萌擦擦* 提交于 2020-01-10 13:18:09
问题 I have a data surface that I'm fitting using SciPy's leastsq function. I would like to have some estimate of the quality of the fit after leastsq returns. I'd expected that this would be included as a return from the function, but, if so, it doesn't seem to be clearly documented. Is there such a return or, barring that, some function I can pass my data and the returned parameter values and fit function to that will give me an estimate of fit quality (R^2 or some such)? Thanks! 回答1: If you

SciPy LeastSq Goodness of Fit Estimator

牧云@^-^@ 提交于 2020-01-10 13:17:52
问题 I have a data surface that I'm fitting using SciPy's leastsq function. I would like to have some estimate of the quality of the fit after leastsq returns. I'd expected that this would be included as a return from the function, but, if so, it doesn't seem to be clearly documented. Is there such a return or, barring that, some function I can pass my data and the returned parameter values and fit function to that will give me an estimate of fit quality (R^2 or some such)? Thanks! 回答1: If you

SciPy LeastSq Goodness of Fit Estimator

半世苍凉 提交于 2020-01-10 13:17:09
问题 I have a data surface that I'm fitting using SciPy's leastsq function. I would like to have some estimate of the quality of the fit after leastsq returns. I'd expected that this would be included as a return from the function, but, if so, it doesn't seem to be clearly documented. Is there such a return or, barring that, some function I can pass my data and the returned parameter values and fit function to that will give me an estimate of fit quality (R^2 or some such)? Thanks! 回答1: If you

Python: fit data to given cosine function

允我心安 提交于 2020-01-02 10:34:10
问题 I am trying to simply find best fit for malus's law. I_measured=I_0*(cos(theta)) ^2 When I scatter the plot, it obviously works but with the def form() function I get the error given below. I googled the problem and it seems that this is not the correct way to curvefit a cosine function. given data is .. x_data=x1 in the code below [ 0.0, 5.0, 10.0, 15.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, 50.0, 55.0, 60.0, 65.0, 70.0, 75.0, 80.0, 85.0, 90.0, 95.0, 100.0, 105.0, 110.0, 115.0, 120.0, 125.0,