gaussian

Can Random.nextgaussian() sample values from a distribution with different mean and standard deviation?

本秂侑毒 提交于 2019-11-27 17:23:50
问题 This is a combined Java and basic math question. The documentation from Random.nextGaussian() states that it samples from a normal distribution with mean 0 and standard deviation 1. What if I wanted to sample from a normal distribution with a different mean and variance? 回答1: The short answer is Random r = new Random(); double mySample = r.nextGaussian()*desiredStandardDeviation+desiredMean; For example this answer is given here: http://www.javamex.com/tutorials/random_numbers/gaussian

Multivariate kernel density estimation in Python

北慕城南 提交于 2019-11-27 14:57:22
问题 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 import stats mu = np.array([1, 10, 20]) sigma = np.matrix([[4, 10, 0], [10, 25, 0], [0, 0, 100]]) data = np.random.multivariate_normal(mu, sigma, 1000) values = data.T kernel = stats.gaussian_kde(values) I saw this but not sure how to extend it to 3D.

How to make a Gaussian filter in Matlab

浪尽此生 提交于 2019-11-27 14:51:52
I have tried to make a Gaussian filter in Matlab without using imfilter() and fspecial() . I have tried this but result is not like the one I have with imfilter and fspecial. Here is my codes. function Gaussian_filtered = Gauss(image_x, sigma) % for single axis % http://en.wikipedia.org/wiki/Gaussian_filter Gaussian_filtered = exp(-image_x^2/(2*sigma^2)) / (sigma*sqrt(2*pi)); end for 2D Gaussian, function h = Gaussian2D(hsize, sigma) n1 = hsize; n2 = hsize; for i = 1 : n2 for j = 1 : n1 % size is 10; % -5<center<5 area is covered. c = [j-(n1+1)/2 i-(n2+1)/2]'; % A product of both axes is 2D

Test if a data distribution follows a Gaussian distribution in MATLAB

我与影子孤独终老i 提交于 2019-11-27 13:46:47
问题 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 looking at different statistical functions provided by MATLAB. I am very new to MATLAB so I might have overlooked the right function. cheers 回答1: Check this documentation page on all available hypothesis tests. From those, for your purpose you can

How to use a custom SVM kernel?

自作多情 提交于 2019-11-27 11:58:52
问题 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 parameters, instead I got it called with X , X as arguments. Looking at the examples things are not clearer. What am I missing? This is my code: ''' Created on 15 Nov 2014 @author: Luigi ''' import scipy.io import numpy as np from sklearn import

Python: finding the intersection point of two gaussian curves

∥☆過路亽.° 提交于 2019-11-27 06:53:17
问题 I have two gaussian plots: x = np.linspace(-5,9,10000) plot1=plt.plot(x,mlab.normpdf(x,2.5,1)) plot2=plt.plot(x,mlab.normpdf(x,5,1)) and I want to find the point at where the two curves intersect. Is there a way of doing this? In particular I want to find the value of the x-coordinate where they meet. 回答1: You want to find the x's such that both gaussian functions have the same height.(i.e intersect) You can do so by equating two gaussian functions and solve for x. In the end you will get a

Low pass gaussian filter with a specified cut off frequency

荒凉一梦 提交于 2019-11-27 06:32:24
问题 I'm playing around with hybrid images, and wanted to use a gaussian filter to low pass filter an image. However, to make hybrid images, 2 filters are supposed to be used on the 2 images being combined with different cut off frequencies. Does fspecial() allow us to specify cut off frequencies when we employ it to make a gaussian filter? (I know that we can specify the filter size and sigma and that there is some relation between sigma and cut off frequency). If we can only specify cut off

JavaScript Math.random Normal distribution (Gaussian bell curve)?

删除回忆录丶 提交于 2019-11-27 04:16:35
问题 I want to know if the JavaScript function Math.random uses a normal (vs. uniform) distribution or not. If not, how can I get numbers which use a normal distribution? I haven't found a clear answer on the Internet, for an algorithm to create random normally-distributed numbers. I want to rebuild a Schmidt-machine (German physicist). The machine produces random numbers of 0 or 1, and they have to be normally-distributed so that I can draw them as a Gaussian bell curve. For example, the random

Gaussian fit for Python

跟風遠走 提交于 2019-11-27 03:41:21
I'm trying to fit a Gaussian for my data (which is already a rough gaussian). I've already taken the advice of those here and tried curve_fit and leastsq but I think that I'm missing something more fundamental (in that I have no idea how to use the command). Here's a look at the script I have so far import pylab as plb import matplotlib.pyplot as plt # Read in data -- first 2 rows are header in this example. data = plb.loadtxt('part 2.csv', skiprows=2, delimiter=',') x = data[:,2] y = data[:,3] mean = sum(x*y) sigma = sum(y*(x - mean)**2) def gauss_function(x, a, x0, sigma): return a*np.exp(-

Fastest Gaussian blur implementation

纵然是瞬间 提交于 2019-11-27 02:54:21
How do you implement the fastest possible Gaussian blur algorithm? I am going to implement it in Java, so GPU solutions are ruled out. My application, planetGenesis , is cross platform, so I don't want JNI . Dima You should use the fact that a Gaussian kernel is separable, i. e. you can express a 2D convolution as a combination of two 1D convolutions. If the filter is large, it may also make sense to use the fact that convolution in the spatial domain is equivalent to multiplication in the frequency (Fourier) domain. This means that you can take the Fourier transform of the image and the