gaussian

Generate a Gaussian kernel given mean and standard deviation

社会主义新天地 提交于 2019-12-11 06:36:19
问题 This question here addresses how to generate a Gaussian kernel using numpy. However I do not understand what the inputs used kernlen and nsig are and how they relate to the mean/standard deviation usually used to describe a Gaussian distribtion. How would I generate a 2d Gaussian kernel described by, say mean = (8, 10) and sigma = 3 ? The ideal output would be a 2-dimensional array representing the Gaussian distribution. 回答1: You could use astropy , especially the Gaussian2D model from the

Unknown label type error when Sklearn naive bayes used with floating point numbers

浪子不回头ぞ 提交于 2019-12-11 03:36:26
问题 I am applying Naive Bayes algorithm on my data which is labelled by floating point numbers. If my Y array consists of int type value then the prediction is coming correctly. See the below code: import numpy as np X = np.array([[0], [1]]) Y = np.array([1, 2]) from sklearn.naive_bayes import GaussianNB clf = GaussianNB() clf.fit(X, Y) print (clf.predict([[0]])) Output is [1] String values are also working. See the below code: import numpy as np X = np.array([[0], [1]]) Y = np.array(['A', 'B'])

Trying to plot multivariate Gaussian dist. in a 3D plot matplotlib returns an empty figure

房东的猫 提交于 2019-12-11 03:18:21
问题 I am trying to plot a Gaussian distribution via matplotlib, but all I get back is an empty figure: When I searched the internet, I understood that three arguments are required for the ax.plot_surface() function, the X values, Y values, and Z (a function that calculates Z from X, Y). Is this correct? I post the code below in hope you can help me figuring out what I am doing wrong here. Thanks! import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D ##########

What is the fastest method of sampling random values from a Gaussian distribution?

扶醉桌前 提交于 2019-12-10 21:42:24
问题 The Box-Muller transform, is an elegant and reasonably performant method of sampling random values from a Gaussian distribution. I'm looking for a faster method clearly written and in C#. For reference here's an implementation of the Box-Muller Implementation to act as a baseline for performance comparisons... public class GaussianGenerator { FastRandom _rng = new FastRandom(); double? _spareValue = null; /// <summary> /// Get the next sample point from the gaussian distribution. /// <

Different 'theta' for Gabor Filter Returns Images with no Orientation

旧街凉风 提交于 2019-12-10 14:28:34
问题 I applied Gabor filter on images with the following theta - {0,45,90,135}. but the resultant images were exactly the same with the same orientation angle! I expected that the results of applying Gabor filter with theta = 90 will be different in orientation than the one with theat = 45 , but after using Gabor filter with different theta , I get images with no difference in orientation! Am I using Gabor filter wrong? Because I expect every image to be of different orientation according to the

why the integral-image contains extra row and column of zeros?

我与影子孤独终老i 提交于 2019-12-10 13:55:12
问题 I am learning how to use the integral-images using opencv with Java API, and i created a test that displays the grayscale image before using the integral-image and after using it. the grayscale image is 10 x 10, and when i converted it to the integral-image i found it 11 x 11 with extra rows of zeros and extra column of zeros as shown below in the output. please let me know why the integral-image contains extra row and column of zeros? Code : public static void main(String[] args) {

Integration in Mathematica

人盡茶涼 提交于 2019-12-10 13:24:12
问题 I would like to get a different solution to a problem I have solved "symbolically" and through a little simulation. Now, I would like to know how could I have got the integration directly using Mathematica. Please consider a target represented by a disk with r = 1, centered at (0,0).I want to do a simulation of my probability to hit this target throwing darts. Now, I have no biases throwing them, that is on average I shall hit the center mu = 0 but my variance is 1. Considering the coordinate

how to generate gaussian pseudo random numbers in c for a given mean and variance?

两盒软妹~` 提交于 2019-12-10 13:18:09
问题 I have a code here which generates random numbers having a mean 0f 1 and std deviation of 0.5. but how do i modify this code so that i can denerate gaussian random numbers of any given mean and variance? #include <stdlib.h> #include <math.h> #ifndef M_PI #define M_PI 3.14159265358979323846 #endif double drand() /* uniform distribution, (0..1] */ { return (rand()+1.0)/(RAND_MAX+1.0); } double random_normal() /* normal distribution, centered on 0, std dev 1 */ { return sqrt(-2*log(drand())) *

Python add gaussian noise in a radius around a point [closed]

别等时光非礼了梦想. 提交于 2019-12-10 12:03:14
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . Given a point (x,y) how would i create n random points that their distance from (x,y) is gaussian distributed with sigma and mean as a param? 回答1: For the 2-D distribution use numpy.random.normal. The trick is that you need to get the distribution for each dimension. So for

Separating gaussian components of a curve using python

蹲街弑〆低调 提交于 2019-12-10 11:01:03
问题 I am trying to deblend the emission lines of low resolution spectrum in order to get the gaussian components. This plot represents the kind of data I am using: After searching a bit, the only option I found was the application of the gauest function from the kmpfit package (http://www.astro.rug.nl/software/kapteyn/kmpfittutorial.html#gauest). I have copied their example but I cannot make it work. I wonder if anyone could please offer me any alternative to do this or how to correct my code: