data-fitting

R: Robust fitting of data points to a Gaussian function

社会主义新天地 提交于 2019-12-09 07:03:28
问题 I need to do some robust data-fitting operation. I have bunch of (x,y) data, that I want to fit to a Gaussian (aka normal) function. The point is, I want to remove the ouliers. As one can see on the sample plot below, there is another distribution of data thats pollutting my data on the right, and I don't want to take it into account to do the fitting (i.e. to find \sigma, \mu and the overall scale parameter). R seems to be the right tool for the job, I found some packages (robust, robustbase

Is there a GNU Octave equivalent for the Matlab function “fit”?

天涯浪子 提交于 2019-12-08 19:49:48
问题 My teacher in the signal analysis course has given me some Matlab code that I have to execute in order to complete a home assignment. I have always been using GNU Octave without troubles, but this time there is this command that is giving me headaches. [c8,g8]=fit(time, sin_4_harmonic,’fourier8’) I cannot find the function "fit" in GNU Octave, which is referenced for Matlab at the following url http://www.mathworks.se/help/curvefit/fit.html Does anyone knows which package should I load, or if

How good is this interpolation method?

浪子不回头ぞ 提交于 2019-12-08 18:42:30
I came up with a custom interpolation method for my problem and I'd like to ask if there are any risks using it. I am not a math or programming expert, that's why I'd like a feedback :) Story: I was searching for a good curve-fit method for my data when I came up with an idea to interpolate the data. I am mixing paints together and making reflectance measurements with a spectrophotometer when the film is dry. I would like to calculate the required proportions of white and colored paints to reach a certain lightness, regardless of any hue shift (e.g. black+white paints gives a bluish grey) or

Fitting Markov Switching Models to data in R

[亡魂溺海] 提交于 2019-12-08 06:43:08
问题 I'm trying to fit two kinds of Markov Switching Models to a time series of log-returns using the package MSwM in R. The models I'm considering are a regression model with only an intercept, and an AR(1) model. Here is the code I'm using: library(tseries) #Prices ftse<-get.hist.quote(instrument="^FTSE", start="1984-01-03", end="2014-01-01", quote="AdjClose", compression="m") #Log-returns ftse.ret<-diff(log(ftse)) library(MSwM) #Model with only intercept mod<-lm(ftse.ret ~ 1) #Fit regime

Memory Error when fitting the data using sklearn package

别说谁变了你拦得住时间么 提交于 2019-12-08 05:42:30
问题 Following my question here: http://stackoverflow.com/questions/37844596/avoid-memory-error-when-dealing-with-large-arrays , I was able to deal with the Memory Error due to arrays operations by splitting them into several lines; thank to the guys responded. The problem now is it's throwing Memory Error when fitting the data using Sklearn packages ; e.g when trying to do .fit(arr_3d[i]) to km in the code below. The array dimension is 3D, and I'm looping through it, so why I'm having this error?

How good is this interpolation method?

扶醉桌前 提交于 2019-12-08 03:47:41
问题 I came up with a custom interpolation method for my problem and I'd like to ask if there are any risks using it. I am not a math or programming expert, that's why I'd like a feedback :) Story: I was searching for a good curve-fit method for my data when I came up with an idea to interpolate the data. I am mixing paints together and making reflectance measurements with a spectrophotometer when the film is dry. I would like to calculate the required proportions of white and colored paints to

Finding the point of a slope change as a free parameter- Python

99封情书 提交于 2019-12-07 21:45:17
问题 Say I have two lists of data as follows: x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y = [1, 2, 3, 4, 5, 6, 8, 10, 12, 14] That is, it's pretty clear that merely fitting a line to this data doesn't work, but instead the slope changed at a point in the data. (Obviously, one can pinpoint from this data set pretty easily where that change is, but it's not as clear in the set I'm working with so let's ignore that.) Something with the derivative, I'm guessing, but the point here is I want to treat this as

Transform data to fit normal distribution

隐身守侯 提交于 2019-12-07 18:16:59
问题 I have a rather easy-to-understand question. I have a set of data and I want to estimate how good this data fit a standard normal distribution . To do so, I start with my code: [f_p,m_p] = hist(data,128); f_p = f_p/trapz(m_p,f_p); x_th = min(data):.001:max(data); y_th = normpdf(x_th,0,1); figure(1) bar(m_p,f_p) hold on plot(x_th,y_th,'r','LineWidth',2.5) grid on hold off Fig. 1 will look like the one below: Easy to see that the fit is quite poor, altough the bell-shape can be spotted. The

fit a function to a histogram created with frequency in gnuplot

ⅰ亾dé卋堺 提交于 2019-12-07 07:51:15
问题 Intro In gnuplot there's a solution to create histogram from file named hist.dat what likes 1 2 2 2 3 by using commands binwidth=1 set boxwidth binwidth bin(x,width)=width*floor(x/width) + binwidth/2.0 plot [0:5][0:*] "hist.dat" u (bin($1,binwidth)):(1.0) smooth freq with boxes that generates a histogram like this one from other SO page. Question How can I fit my function to this histogram? I defined a Gaussian function and initialized its values by f(x) = a*exp(-((x-m)/s)**2) a=3; m=2.5; s=1

Python: fit data to given cosine function

為{幸葍}努か 提交于 2019-12-06 11:51:57
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, 130.0, 135.0, 140.0, 145.0, 150.0, 155.0, 160.0, 165.0, 170.0, 175.0, 180.0, 185.0, 190.0, 195.0, 200.0,