data-fitting

R Package segmented with an offset term

眉间皱痕 提交于 2019-12-11 18:04:38
问题 I am using package segmented in R. I first fitted a Poisson glm with a log link function using the glm function that includes an offset term like: M1=glm(Y~X1+X2+X3+offset(log(X)),data=dat.1,family=poisson) M1 is fitted without any error. Next I tried to fit a segmented glm by using the package segmented in R as: library(segmented) seg.1=segmented(M1,seg.Z=~X1,psi=list(X1=c(0.5))) I am having the following error: Error in offset(log(X)) : object 'X' not found Where is my mistake here? Thanks

Fitting a sum of functions with fixed parameter in python

好久不见. 提交于 2019-12-11 12:12:57
问题 The signal I want to fit is a superposition of multiple sine-functions (and noise) and I want to fit for all frequencies simultaneously. Here an example data file, generated with two frequencies of 240d^-1 and 261.8181d^-1: https://owncloud.gwdg.de/index.php/s/JZQTJ3VMYZH8qNB and plot of the time series (excerpt) So far I can fit one sine-function after the other, while keeping the frequency fixed to a value. I get the frequency from e.g. a periodogram and in the end I am interested in

Using fminsearch to perform distribution fitting

送分小仙女□ 提交于 2019-12-11 09:54:03
问题 Suppose I have a set of univariate data held in the array errors . I would like to fit a PDF to my observed data distribution. My PDF is defined in a function poissvmwalkpdf , whose definition line looks like this: function p = poissvmwalkpdf(theta, mu, kappa, xi) Here, theta is the error (the variable for which values in errors are instances), and mu , kappa , and xi are parameters of the PDF for which I want to find the best fit using maximum-likelihood estimation. This function returns the

scipy.integrate Pseudo-Voigt function, integral becomes 0

落花浮王杯 提交于 2019-12-11 06:44:38
问题 I am writing a script for fitting peak shapes to spectroscopic data in Python, using Scipy, Numpy and Matplotlib. It can fit multiple peaks at once. The peak profile (for now) is Pseudo-Voigt, which is a linear combination of a Gaussian (aka Normal) and Lorentzian (aka Cauchy) distribution. I have an option switch with which I can either let the software optimize the contribution of Gaussian and Lorentzian or set it to a fixed value (where 0 = pure Gaussian and 1 = pure Lorentzian). Works as

Troubles fitting exponential with gnuplot

被刻印的时光 ゝ 提交于 2019-12-11 04:47:43
问题 I have a file called 'dataset.txt' with inside these data #Temperature (K) - Pressure (kPa) 310.2 5.349 315.6 6.682 320.2 8.015 325.2 10.681 330.2 14.680 335.2 17.346 340.2 22.678 345.2 28.010 350.2 34.675 355.2 44.006 360.2 52.004 365.2 62.668 370.2 73.332 I have to fit the curve given by data with an exponential of the form f(x) = a * exp(x * b) + c So i digit f(x) = a*exp(x*b) + c fit f(x) 'dataset.txt' u 1:2 via a, b, c but I get an error of the type Current data point ===================

Data series, how can i fit a distribution in R?

夙愿已清 提交于 2019-12-11 02:45:28
问题 I have some problems with a Data series because it has some zero values so there are some distributions who don't fit it. I've tried with the function fitdist and fitdistr but no one works. There are my data: Precp 28 8 0 107 339 231 308 226 302 333 163 92 48 17 101 327 424 338 559 184 238 371 413 261 12 24 103 137 300 446 94 313 402 245 147 70 8 5 59 109,2 493,6 374,5 399,3 330,5 183,8 341,1 91 127,5 15 69 165,8 337,9 255 309,3 352,7 437,5 420,4 295,6 141,7 3,4 16,2 58,9 55,5 203,1 235 300

Fit a sigmoid to my data using MATLAB

有些话、适合烂在心里 提交于 2019-12-10 15:38:01
问题 I have a lot of data, and I think it is possible to fit it to a sigmoid (this thought based on my eye-sight, not a mathematical formula). How can I find the parametric form with statistically significant explanatory power of the best sigmoid for my data? Thanks! 回答1: One great thing that you can do is to use the "Curve fitting" App in Matlab. you can find it in APPS, in "Math, statistics and optimization" section. over there you can choose your x and y data and the function that you want to

Fitting complex model using Python and lmfit?

我是研究僧i 提交于 2019-12-10 13:37:30
问题 I would like to fit ellipsometric data to complex model using lmfit. Two measured parameters, psi and delta , are variables in a complex function rho . I could try with separating problem to real and imaginary part with shared parameters or picewise approach, but is there any way to do it directly with complex function? Fitting only real part of function works beautifully, but when I define complex residual function I get: TypeError: no ordering relation is defined for complex numbers. Below

How to weigh the points in a scatter plot for a fit?

半城伤御伤魂 提交于 2019-12-10 12:31:42
问题 So, I looked up information about the weights parameter in the polyfit (numpy.polynomial.polynomial.polyfit) function in Python and it seems like it has something to do with the error associated with the individual points. (How to include measurement errors in numpy.polyfit) However, what I am trying to do has nothing to do with the error, but weights. I have an image in the form of a numpy array which indicates the amount of charge deposited in the detector. I convert that image to a scatter

Fitting an ellipse to a set of data points in python

这一生的挚爱 提交于 2019-12-09 13:34:56
问题 I have a 2D points (x,y), and I want to fit the ellipse using this post fit a ellipse in Python given a set of points xi=(xi,yi) But my result is axes = [ 0.93209407 nan] since in function ellipse_axis_length the down2 is a minus number, so res2 is invalid, how to do with this? and if I want to draw an ellipse according to the dataset, and calculate the error between the data points and the ellipse, how could I do? and the code is like this: import numpy as np import numpy.linalg as linalg