gaussian

How do I get minuit.Minuit to fit a gaussian curve to my data in Python?

一曲冷凌霜 提交于 2019-12-13 01:25:36
问题 I am trying to fit a gaussian to some simple data using the minuit.Minuit function but it doesnt change any of my parameters. If anyone can help out I would be very grateful. import numpy as np import minuit xCurve = np.array([0,1,2,3,4,5,6,7,8,9]) yCurve = np.array([0,1,2,3,4,5,4,3,2,1]) def Gaus(a,b,c): return a*np.exp(-((xCurve-b)**2)/(2*c**2)) m = minuit.Minuit(Gaus,a=4.5,b=5,c=0.4) m.printMode=1 m.migrad() m.printMode=0 m.values() a = m.values['a'] b = m.values['b'] c = m.values['c'] d =

Gaussian Curve-fitting algorithm

邮差的信 提交于 2019-12-12 18:19:58
问题 Folks,i have been trying to obtain a Gaussian fit for some data sets which somehow look like a distorted normal distribution.I have been using software to do that. I wonder if i can apply an iterative algorithm to convert these data sets to a Gaussian fitted curve,the standard deviation and mean of the original curve being the inputs.? Any ideas? 回答1: Calculate the mean of the data: mu = 1/N Sum(xi) Calculate the dispersion of the data: sigma = sqrt(1/(N-1) Sum(xi-mu)) Fill in the parameters:

How to apply a partial derivative Gaussian kernel to an image with OpenCV?

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 17:15:22
问题 I'm trying reproduce results from a paper, in which they convolve the image with an horizontal partial derivative of a Gaussian kernel. I haven't found any way to achieve that with OpenCV. Is that possible ? Do I have to get Gaussian filter and then compute the partial derivatives by hand ? 回答1: OpenCV doesn't have built-in function to calculate Gaussian partial derivatives. But you may use cv::getGaussianKernel and cv::filter2D to do so. For example: cv::Mat kernel = cv::getGaussianKernel(3,

Using matlab function “pdf”

这一生的挚爱 提交于 2019-12-12 16:53:35
问题 I have got a Gaussian mixture distribution object obj of 64 dimensions and would like to put it in the pdf function to find out the probability of certain point. Yet when I type pdf(obj,obj.mu(1,:)) to test the object it yield a very high probability (like 2.4845e+069) And it does not make sense, cause probability should lies between zero and one. Is my matlab having any problem? p.s. even pdf(obj,obj.mu(1,:)+obj.Sigma(1,1)*rand()) yield a high probability (2.1682e+069) 回答1: First things

Fitting (a gaussian) with Scipy vs. ROOT et al

会有一股神秘感。 提交于 2019-12-12 16:45:11
问题 I have now multiple times stumbled upon that fitting in python with scipy.curve_fit is somehow a lot harder than with other tools like e.g. ROOT (https://root.cern.ch/) For example, when fitting a gaussian, with scipy I mostly get a straight line: corresponding code: def fit_gauss(y, x = None): n = len(y) # the number of data if x is None: x = np.arange(0,n,1) mean = y.mean() sigma = y.std() def gauss(x, a, x0, sigma): return a * np.exp(-(x - x0) ** 2 / (2 * sigma ** 2)) popt, pcov = curve

Gaussian Filter without using ConvolveOp

落花浮王杯 提交于 2019-12-12 09:59:46
问题 I am trying to create a guassian filter without using ConvolveOp. I am having a lot of problems trying to get this to work, i have gotten a grey scale filter to work, but for this one i am having problems finding the location of a pixels 8 neighbors, so i can apply the filter. here is what i have so far. Is this the right way to approach getting each of the pixels? public class Gaussian implements Filter { public void filter(PixelImage pi) { Pixel[][] data = pi.getData(); Pixel[][] original =

Gaussian Process scikit-learn - Exception

我只是一个虾纸丫 提交于 2019-12-12 07:59:39
问题 I want to use Gaussian Processes to solve a regression task. My data is as follow : each X vector has a length of 37, and each Y vector has a length of 8. I'm using the sklearn package in Python but trying to use gaussian processes leads to an Exception : from sklearn import gaussian_process print "x :", x__ print "y :", y__ gp = gaussian_process.GaussianProcess(theta0=1e-2, thetaL=1e-4, thetaU=1e-1) gp.fit(x__, y__) x : [[ 136. 137. 137. 132. 130. 130. 132. 133. 134. 135. 135. 134. 134. 1139

Python gaussian fit on simulated gaussian noisy data

不打扰是莪最后的温柔 提交于 2019-12-12 05:40:09
问题 I need to interpolate data coming from an instrument using a gaussian fit. To this end I thought about using the curve_fit function from scipy . Since I'd like to test this functionality on fake data before trying it on the instrument I wrote the following code to generate noisy gaussian data and to fit it: from scipy.optimize import curve_fit import numpy import pylab # Create a gaussian function def gaussian(x, a, b, c): val = a * numpy.exp(-(x - b)**2 / (2*c**2)) return val # Generate fake

Three-term gaussian fit to gaussian data (python)

我是研究僧i 提交于 2019-12-12 03:45:55
问题 I am trying to fit a gaussian data to a specific three-term gaussian (in which the amplitude in one term is equal to twice the standard deviation of the next term). Here is my attempt: import numpy as np #from scipy.optimize import curve_fit import scipy.optimize as optimize import matplotlib.pyplot as plt #r=np.linspace(0.0e-15,4e-15, 100) data = np.loadtxt('V_lambda_n.dat') r = data[:, 0] V = data[:, 1] def func(x, ps1, ps2, ps3, ps4): return ps1*np.exp(-(x/ps2)**2) + ps2*np.exp(-(x/ps3)**2

UIImageEffects: white image when Gaussian radius above 280, vImageBoxConvolve_ARGB8888 issue?

五迷三道 提交于 2019-12-11 21:22:31
问题 I'm using the Gaussian blur algorithm found in Apple's UIImageEffects example: CGFloat inputRadius = blurRadius * inputImageScale; if (inputRadius - 2. < __FLT_EPSILON__) inputRadius = 2.; uint32_t radius = floor((inputRadius * 3. * sqrt(2 * M_PI) / 4 + 0.5) / 2); radius |= 1; // force radius to be odd so that the three box-blur methodology works. NSInteger tempBufferSize = vImageBoxConvolve_ARGB8888(inputBuffer, outputBuffer, NULL, 0, 0, radius, radius, NULL, kvImageGetTempBufferSize |