gaussian

Gauss Elimination for NxM matrix

老子叫甜甜 提交于 2019-12-03 06:25:54
问题 /* 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;

when generating normally-distributed random values, what is the most efficient way to define the range?

爷,独闯天下 提交于 2019-12-03 03:55:01
FYI: random == pseudo-random A. when generating uniformly-random numbers, I can specify a range, i.e.: (Math.random()-Math.random())*10+5 //generates numbers between -5 and 15 B. generating a set of random values with a version of Gaussian-esque normal randomness: //pass in the mean and standard deviation function randomNorm(mean, stdev) { return Math.round((Math.random()*2-1)+(Math.random()*2-1)+(Math.random()*2-1))*stdev+mean); } //using the following values: { mean:400, standard_deviation:1 //results in a range of 397-403, or +-range of 3 }, { mean:400, standard_deviation:10 //results in a

How to obtain a gaussian filter in python

回眸只為那壹抹淺笑 提交于 2019-12-03 03:47:32
问题 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 /

Gaussian Blur - standard deviation, radius and kernel size

ⅰ亾dé卋堺 提交于 2019-12-03 03:01:27
I've implemented a gaussian blur fragment shader in GLSL. I understand the main concepts behind all of it: convolution, separation of x and y using linearity, multiple passes to increase radius... I still have a few questions though: What's the relationship between sigma and radius? I've read that sigma is equivalent to radius, I don't see how sigma is expressed in pixels. Or is "radius" just a name for sigma, not related to pixels? How do I choose sigma? Considering I use multiple passes to increase sigma, how do I choose a good sigma to obtain the sigma I want at any given pass? If the

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

末鹿安然 提交于 2019-12-03 02:51:57
问题 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

How can I fit a gaussian curve in python?

左心房为你撑大大i 提交于 2019-12-03 02:24:36
I'm given an array and when I plot it I get a gaussian shape with some noise. I want to fit the gaussian. This is what I already have but when I plot this I do not get a fitted gaussian, instead I just get a straight line. I've tried this many different ways and I just can't figure it out. random_sample=norm.rvs(h) parameters = norm.fit(h) fitted_pdf = norm.pdf(f, loc = parameters[0], scale = parameters[1]) normal_pdf = norm.pdf(f) plt.plot(f,fitted_pdf,"green") plt.plot(f, normal_pdf, "red") plt.plot(f,h) plt.show() You can use fit from scipy.stats.norm as follows: import numpy as np from

Plotting of 1-dimensional Gaussian distribution function

廉价感情. 提交于 2019-12-03 01:59:43
How do I make plots of a 1-dimensional Gaussian distribution function using the mean and standard deviation parameter values (μ, σ) = (−1, 1), (0, 2), and (2, 3)? I'm new to programming, using Python. Thank you in advance! With the excellent matplotlib and numpy packages from matplotlib import pyplot as mp import numpy as np def gaussian(x, mu, sig): return np.exp(-np.power(x - mu, 2.) / (2 * np.power(sig, 2.))) x_values = np.linspace(-3, 3, 120) for mu, sig in [(-1, 1), (0, 2), (2, 3)]: mp.plot(x_values, gaussian(x_values, mu, sig)) mp.show() will produce something like you can read this

Best way to write a Python function that integrates a gaussian?

痞子三分冷 提交于 2019-12-03 00:32:08
In attempting to use scipy's quad method to integrate a gaussian (lets say there's a gaussian method named gauss), I was having problems passing needed parameters to gauss and leaving quad to do the integration over the correct variable. Does anyone have a good example of how to use quad w/ a multidimensional function? But this led me to a more grand question about the best way to integrate a gaussian in general. I didn't find a gaussian integrate in scipy (to my surprise). My plan was to write a simple gaussian function and pass it to quad (or maybe now a fixed width integrator). What would

How to correctly use scikit-learn's Gaussian Process for a 2D-inputs, 1D-output regression?

倖福魔咒の 提交于 2019-12-02 23:56:21
Prior to posting I did a lot of searches and found this question which might be exactly my problem. However, I tried what is proposed in the answer but unfortunately this did not fix it, and I couldn't add a comment to request further explanation, as I am a new member here. Anyway, I want to use the Gaussian Processes with scikit-learn in Python on a simple but real case to start (using the examples provided in scikit-learn's documentation). I have a 2D input set (8 couples of 2 parameters) called X . I have 8 corresponding outputs, gathered in the 1D-array y . # Inputs: 8 points X = np.array(

Gaussian blur and convolution kernels

两盒软妹~` 提交于 2019-12-02 22:51:59
I do not understand what a convolution kernel is and how I would apply a convolution matrix to pixels in an image (I am talking about doing a Gaussian Blur operation on an image). Also could I get an explanation on how to create a kernel for a Gaussian Blur operation? I am reading this article but I cannot seem to understand how things are done... Thanks to anyone who takes time to explain this to me :), ExtremeCoder The basic idea is that the new pixels of the image are created by an weighted average of the pixels close to it (imagine drawing a circle around the pixel). For each pixel in the