gaussian

Gauss Elimination for NxM matrix

本小妞迷上赌 提交于 2019-12-02 20:59:59
/* Program to demonstrate gaussian <strong class="highlight">elimination</strong> on a set of linear simultaneous equations */ #include <iostream> #include <cmath> #include <vector> using namespace std; const double eps = 1.e-15; /*Preliminary pivoting strategy Pivoting function */ double pivot(vector<vector<double> > &a, vector<double> &b, int i) { int n = a.size(); int j=i; double t=0; for(int k=i; k<n; k+=1) { double aki = fabs(a[k][i]); if(aki>t) { t=aki; j=k; } } if(j>i) { double dummy; for(int L=0; L<n; L+=1) { dummy = a[i][L]; a[i][L]= a[j][L]; a[j][L]= dummy; } double temp = b[j]; b[i]

Normalization by using 2 times gaussian function on negative and positive numbers of data in dataframe

半世苍凉 提交于 2019-12-02 20:13:33
问题 I'm trying to read the dataset from text file and extract 3 main parameters and put them in separate list and apply normalization on lists of parameters which are (A, B, C) after assigning Gaussian distribution function. For getting good result I split up positive and negative numbers of each parameters' list and apply gaussian distribution function on them separately and pick: mean value of negative numbers as the real Minimum mean value of positive numbers as the real Maximum instead of

How to obtain a gaussian filter in python

依然范特西╮ 提交于 2019-12-02 17:36:33
I am using python to create a gaussian filter of size 5x5. I saw this post here where they talk about a similar thing but I didn't find the exact way to get equivalent python code to matlab function fspecial('gaussian', f_wid, sigma) Is there any other way to do it? I tried using the following code : size = 2 sizey = None size = int(size) if not sizey: sizey = size else: sizey = int(sizey) x, y = scipy.mgrid[-size: size + 1, -sizey: sizey + 1] g = scipy.exp(- (x ** 2/float(size) + y ** 2 / float(sizey))) print g / np.sqrt(2 * np.pi) The output obtained is [[ 0.00730688 0.03274718 0.05399097 0

How can I perform a least-squares fitting over multiple data sets fast?

喜夏-厌秋 提交于 2019-12-02 16:25:55
I am trying to make a gaussian fit over many data points. E.g. I have a 256 x 262144 array of data. Where the 256 points need to be fitted to a gaussian distribution, and I need 262144 of them. Sometimes the peak of the gaussian distribution is outside the data-range, so to get an accurate mean result curve-fitting is the best approach. Even if the peak is inside the range, curve-fitting gives a better sigma because other data is not in the range. I have this working for one data point, using code from http://www.scipy.org/Cookbook/FittingData . I have tried to just repeat this algorithm, but

Random number within a range based on a normal distribution

丶灬走出姿态 提交于 2019-12-02 16:13:51
I want to generate random numbers with a range (n to m, eg 100 to 150), but instead of purely random I want the results to be based on the normal distribution. By this I mean that in general I want the numbers "clustered" around 125. I've found this random number package that seems to have a lot of what I need: http://codeproject.com/KB/recipes/Random.aspx It supports a variety of random generators (include mersiene twister) and can apply the generator to a distribution. But I'm confused, if I use a normal distribution generator the random numbers are from roughly -6 to +8 (apparently the true

Fitting a better gaussian to data points?

删除回忆录丶 提交于 2019-12-02 13:14:42
问题 I am trying to fit a gaussian to a set of data points that seem to follow a gaussian distribution. I have already checked a lot of possible ways to do that, but I don't really understand most of them. However, I found one solution that seems to work, but the actual fit I get does not look much more like a gaussian than my data points. Here is my code: import numpy as np import matplotlib.pyplot as plt from scipy import asarray as ar, exp, sqrt from scipy.optimize import curve_fit angles = [-8

How to fix 'Float' object has no attribute 'exp'?

a 夏天 提交于 2019-12-02 13:12:13
问题 I have the following Gaussian equation in Python: numpy.exp((-(x-m)**2)/(2*sigma)) Provided that x is an matrix. However, the equation won't run, and I get the following error: AttributeError: 'Float' object has no attribute 'exp' How can I solve this issue? EDIT-1 Making the following edit: map(float(),np.exp((-(x-m)**2)/(2*sigma))) Raised the error: TypeError: 'float' object is not callable EDIT-2 This is a sample of the value x : [[-0.20646505 0.07763347 -0.16161097 0.370439 ] [-0.91295327

How to fix 'Float' object has no attribute 'exp'?

筅森魡賤 提交于 2019-12-02 07:28:14
I have the following Gaussian equation in Python: numpy.exp((-(x-m)**2)/(2*sigma)) Provided that x is an matrix. However, the equation won't run, and I get the following error: AttributeError: 'Float' object has no attribute 'exp' How can I solve this issue? EDIT-1 Making the following edit: map(float(),np.exp((-(x-m)**2)/(2*sigma))) Raised the error: TypeError: 'float' object is not callable EDIT-2 This is a sample of the value x : [[-0.20646505 0.07763347 -0.16161097 0.370439 ] [-0.91295327 -0.73768934 -0.78909055 0.06156045] [-0.37242104 0.51828245 -1.16138222 -0.02489585] [-1.07890926 -0

Fitting a better gaussian to data points?

好久不见. 提交于 2019-12-02 04:27:59
I am trying to fit a gaussian to a set of data points that seem to follow a gaussian distribution. I have already checked a lot of possible ways to do that, but I don't really understand most of them. However, I found one solution that seems to work, but the actual fit I get does not look much more like a gaussian than my data points. Here is my code: import numpy as np import matplotlib.pyplot as plt from scipy import asarray as ar, exp, sqrt from scipy.optimize import curve_fit angles = [-8, -6, -4, -2, 0, 2, 4, 6, 8] data = [99, 610, 1271, 1804, 1823, 1346, 635, 125, 24] angles = ar(angles)

(Matlab) Performance of Gaussian filtering using imfilter on a binary image

五迷三道 提交于 2019-12-02 03:30:01
I am currently coding a program to keep track of a running fly in a small chamber, what I want is XY-coordinates of the center of the fly. For this I first filter each frame with a Gaussian filter using fspecial('gaussian',[30 30],100) and imfilter to get a white "cloud" where the fly is. I need this to reduce noise of the center of the fly. I convert the outcome into a binary image using im2bw with a certain threshold to get a white blob from the aforementioned cloud. To get the coordinates, I use regionprops that finds the centroid of the white blob. It already works fine, but it takes ages