Questions tagged [gaussian]

For issues related to any of the uses of the Gaussian function. Don't forget to add additional tags to clarify the context.

The graph of a Gaussian is a characteristic symmetric "bell curve" shape that quickly falls off towards plus/minus infinity. The 1-D Gaussian is defined as (taken from wikipedia):

gaussian function from wikipedia

The parameter a is the height of the curve's peak, b is the position of the centre of the peak, and c controls the width of the "bell".

In multiple dimensions, the Gaussian is defined as the product of 1D curves along each dimension.

Gaussian functions are widely used in statistics where they describe the normal distributions, in signal processing where they serve to define Gaussian filters, in image processing where two-dimensional Gaussians are used for Gaussian blurs, in mathematics and physics where they are used to solve heat equations and diffusion equations, to formulate the propagation of optical beams (Gaussian beams), to from a basis set of wavefunctions, to define the Weierstrass transform, and many more.

1812 questions
24
votes
2 answers

How can I fit a gaussian curve in python?

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…
P. Kaur
  • 255
  • 1
  • 2
  • 11
21
votes
7 answers

Generating a gaussian distribution with only positive numbers

Is there any way to randomly generate a set of positive numbers such that they have a desired mean and standard deviation? I have an algorithm to generate numbers with a gaussian distribution, but I don't know how to deal with negative numbers in…
Whatsit
  • 10,227
  • 11
  • 42
  • 41
19
votes
3 answers

Python: two-curve gaussian fitting with non-linear least-squares

My knowledge of maths is limited which is why I am probably stuck. I have a spectra to which I am trying to fit two Gaussian peaks. I can fit to the largest peak, but I cannot fit to the smallest peak. I understand that I need to sum the Gaussian…
Harpal
  • 12,057
  • 18
  • 61
  • 74
18
votes
1 answer

OpenCV Error: Assertion failed (ksize.width > ...... for GaussianBlur

when I call Imgproc.GaussianBlur(dst, dst ,new Size(3,3),1); in my application it works perfectly fine. As soon as I increase the kernel size to new Size(4,4) or else I get an OpenCV Error: Assertion failed (ksize.width > 0 && ksize.width % 2 == 1…
Mr.Fu
  • 1,763
  • 2
  • 11
  • 6
18
votes
2 answers

How to use a custom SVM kernel?

I'd like to implement my own Gaussian kernel in Python, just for exercise. I'm using: sklearn.svm.SVC(kernel=my_kernel) but I really don't understand what is going on. I expect the function my_kernel to be called with the columns of the X matrix as…
Luigi Tiburzi
  • 4,265
  • 7
  • 32
  • 43
18
votes
2 answers

Multivariate kernel density estimation in Python

I am trying to use SciPy's gaussian_kde function to estimate the density of multivariate data. In my code below I sample a 3D multivariate normal and fit the kernel density but I'm not sure how to evaluate my fit. import numpy as np from scipy…
akhil
  • 839
  • 3
  • 8
  • 15
18
votes
4 answers

Creating a Gaussian Random Generator with a mean and standard deviation

I am trying to create a one dimensional array and use a random number generator(Gaussian generator that generates a random number with means of 70 and a standard deviation of 10) to populate the array with at least 100 numbers between 0 and 100…
coder_For_Life22
  • 26,645
  • 20
  • 86
  • 118
17
votes
3 answers

Gaussian blur and convolution kernels

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…
user400055
17
votes
3 answers

Test if a data distribution follows a Gaussian distribution in MATLAB

I have some data points and their mean point. I need to find whether those data points (with that mean) follows a Gaussian distribution. Is there a function in MATLAB which can do that kind of a test? Or do I need to write a test of my own? I tried…
Arnkrishn
  • 29,828
  • 40
  • 114
  • 128
17
votes
1 answer

Gaussian Smoothing an image in python

I am very new to programming in python, and im still trying to figure everything out, but I have a problem trying to gaussian smooth or convolve an image. This is probably an easy fix, but I've spent so much time trying to figure it out im starting…
Jenn
  • 171
  • 1
  • 1
  • 4
16
votes
2 answers

Python unsharp mask

I want to use unsharp mask on a 16 Bit Image. The Image has 640 x 480 Pixels and is saved in a NumPy array. I have done the following: blurred the image with a Gaussian filter (three different methods) then, created a mask by subtracting the blur…
omni
  • 161
  • 1
  • 1
  • 6
16
votes
4 answers

Optimal sigma for Gaussian filtering of an image?

When applying a Gaussian blur to an image, typically the sigma is a parameter (examples include Matlab and ImageJ). How does one know what sigma should be? Is there a mathematical way to figure out an optimal sigma? In my case, i have some objects…
Tony Stark
  • 24,588
  • 41
  • 96
  • 113
15
votes
3 answers

Plotting a gaussian fit to a histogram in displot or histplot

How can I plot a gaussian fit onto a histplot, as previously done by the deprecated distplot? import seaborn as sns import numpy as np from scipy.stats import norm x = np.random.normal(size=500) * 0.1 With distplot I could do: sns.distplot(x,…
UserR6
  • 493
  • 7
  • 15
15
votes
4 answers

Laplacian of gaussian filter use

This is a formula for LoG filtering: (source: ed.ac.uk) Also in applications with LoG filtering I see that function is called with only one parameter: sigma(σ). I want to try LoG filtering using that formula (previous attempt was by gaussian…
maximus
  • 4,201
  • 15
  • 64
  • 117
15
votes
3 answers

Why use log-probability estimates in GaussianNB [scikit-learn]?

I'm currently using scikit-learn's GaussianNB package. I've noticed that I can choose to return results for the classification several different ways. One way to return a classification is using the predict_log_proba method. Why would I choose to…
T.S.
  • 1,009
  • 2
  • 11
  • 24