gaussian

C++: generate gaussian distribution

谁说我不能喝 提交于 2019-11-26 21:37:24
问题 I would like to know if in C++ standard libraries there is any gaussian distribution number generator, or if you have any code snippet to pass. Thanks in advance. 回答1: The standard library does not. Boost.Random does, however. I'd use that if I were you. 回答2: C++ Technical Report 1 adds support for random number generation. So if you're using a relatively recent compiler (visual c++ 2008 GCC 4.3), chances are that it is available out of the box. See here for sample usage of std::tr1::normal

Creating a Gaussian Random Generator with a mean and standard deviation

北城余情 提交于 2019-11-26 21:12:59
问题 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 inclusive. How would i go about doing this in C++ ? 回答1: In C++11 this is relatively straight forward using the random header and std::normal_distribution ( live example ): #include <iostream> #include <iomanip> #include <string> #include <map>

By which measures should I set the size of my Gaussian filter in MATLAB?

你。 提交于 2019-11-26 21:04:45
问题 I'm trying to learn image processing using MATLAB and I have read about filters on images. By considering this code: gaussianFilter = fspecial('gaussian', [7, 7], 5) , this builds a Gaussian filter matrix of 7 rows and 7 columns, with standard deviation of 5. As such, the size of filter matrix is 7 x 7 . How can the size of this matrix be effective on filtering? (What does this matrix do ?) By which measures should I set the size of filter matrix in my code? 回答1: One of the most common and

How to fit a gaussian to data in matlab/octave?

江枫思渺然 提交于 2019-11-26 20:58:20
问题 I have a set of frequency data with peaks to which I need to fit a Gaussian curve and then get the full width half maximum from. The FWHM part I can do, I already have a code for that but I'm having trouble writing code to fit the Gaussian. Does anyone know of any functions that'll do this for me or would be able to point me in the right direction? (I can do least squares fitting for lines and polynomials but I can't get it to work for gaussians) Also it would be helpful if it was compatible

How to make a Gaussian filter in Matlab

北城余情 提交于 2019-11-26 16:56:33
问题 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 %

Overlay normal curve to histogram in R

瘦欲@ 提交于 2019-11-26 15:11:43
I have managed to find online how to overlay a normal curve to a histogram in R, but I would like to retain the normal "frequency" y-axis of a histogram. See two code segments below, and notice how in the second, the y-axis is replaced with "density". How can I keep that y-axis as "frequency", as it is in the first plot. AS A BONUS: I'd like to mark the SD regions (up to 3 SD) on the density curve as well. How can I do this? I tried abline , but the line extends to the top of the graph and looks ugly. g = d$mydata hist(g) g = d$mydata m<-mean(g) std<-sqrt(var(g)) hist(g, density=20, breaks=20,

Random Gaussian Variables

柔情痞子 提交于 2019-11-26 12:51:03
Is there a class in the standard library of .NET that gives me the functionality to create random variables that follow Gaussian distribution? Jarrett's suggestion of using a Box-Muller transform is good for a quick-and-dirty solution. A simple implementation: Random rand = new Random(); //reuse this if you are generating many double u1 = 1.0-rand.NextDouble(); //uniform(0,1] random doubles double u2 = 1.0-rand.NextDouble(); double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math.Sin(2.0 * Math.PI * u2); //random normal(0,1) double randNormal = mean + stdDev * randStdNormal; //random

Fastest Gaussian blur implementation

大憨熊 提交于 2019-11-26 12:36:24
问题 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. 回答1: 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

Gaussian fit for Python

拟墨画扇 提交于 2019-11-26 10:36:17
问题 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 =

Random Gaussian Variables

China☆狼群 提交于 2019-11-26 03:37:24
问题 Is there a class in the standard library of .NET that gives me the functionality to create random variables that follow Gaussian distribution? 回答1: Jarrett's suggestion of using a Box-Muller transform is good for a quick-and-dirty solution. A simple implementation: Random rand = new Random(); //reuse this if you are generating many double u1 = 1.0-rand.NextDouble(); //uniform(0,1] random doubles double u2 = 1.0-rand.NextDouble(); double randStdNormal = Math.Sqrt(-2.0 * Math.Log(u1)) * Math