Questions tagged [normal-distribution]

The normal distribution is an assumption of many parametric statistical tests, and is typically associated with a Gaussian distribution, often with mean=0 and standard deviation=1. The "bell curve" is the visual, intuitive model for this distribution. Gaussian distributions are associated with the function: f(x) = [1/(σ√2π)] e^(-[(x-μ)^2]/(2σ^2 ))

In scientific software for statistical computing and graphics, we can use dnorm function to compute density of a normal distribution, rnorm function to generate random samples from a normal distribution, pnorm function to compute CDF of a normal distribution and qnorm function to compute quantiles of a normal distribution.

1278 questions
128
votes
18 answers

Generate random numbers following a normal distribution in C/C++

How can I easily generate random numbers following a normal distribution in C or C++? I don't want any use of Boost. I know that Knuth talks about this at length but I don't have his books at hand right now.
Damien
  • 1,423
  • 2
  • 11
  • 7
106
votes
3 answers

How to calculate the inverse of the normal cumulative distribution function in python?

How do I calculate the inverse of the cumulative distribution function (CDF) of the normal distribution in Python? Which library should I use? Possibly scipy?
Yueyoum
  • 2,823
  • 5
  • 23
  • 26
65
votes
8 answers

Generating random numbers with normal distribution in Excel

I want to produce 100 random numbers with normal distribution (with µ=10, σ=7) and then draw a quantity diagram for these numbers. How can I produce random numbers with a specific distribution in Excel 2010? One more question: When I produce, for…
ha.M.ed
  • 925
  • 4
  • 11
  • 19
59
votes
8 answers

Seeing if data is normally distributed in R

Can someone please help me fill in the following function in R: #data is a single vector of decimal values normally.distributed <- function(data) { if(data is normal) return(TRUE) else return(NO) }
CodeGuy
  • 28,427
  • 76
  • 200
  • 317
55
votes
2 answers

Java normal distribution

I'm trying to simulate the arrival of fans to a stadium. The system itself, I believe it won't be a problem, but, the arrival of the fans follows a normal distribution. My problem is: I have a certain time for the arrival like 100 minutes and 1000…
Henrique Gonçalves
  • 1,572
  • 3
  • 16
  • 27
49
votes
4 answers

How to get a normal distribution within a range in numpy?

In machine learning task. We should get a group of random w.r.t normal distribution with bound. We can get a normal distribution number with np.random.normal() but it does't offer any bound parameter. I want to know how to do that?
maple
  • 1,828
  • 2
  • 19
  • 28
39
votes
4 answers

Sample from multivariate normal/Gaussian distribution in C++

I've been hunting for a convenient way to sample from a multivariate normal distribution. Does anyone know of a readily available code snippet to do that? For matrices/vectors, I'd prefer to use Boost or Eigen or another phenomenal library I'm not…
JCooper
  • 6,395
  • 1
  • 25
  • 31
33
votes
4 answers

What is the difference between random.normalvariate() and random.gauss() in python?

What is the difference between random.normalvariate() and random.gauss()? They take the same parameters and return the same value, performing essentially the same function. I understand from a previous answer that random.gauss() is not thread safe,…
richnis
  • 561
  • 5
  • 10
33
votes
4 answers

Perform a Shapiro-Wilk Normality Test

I want to perform a Shapiro-Wilk Normality Test test. My data is csv format. It looks like this: heisenberg HWWIchg 1 -15.60 2 -21.60 3 -19.50 4 -19.10 5 -20.90 6 -20.70 7 -19.30 8 -18.30 9 -15.10 However, when I…
maximus
  • 11,264
  • 30
  • 93
  • 124
29
votes
4 answers

Code to generate Gaussian (normally distributed) random numbers in Ruby

What is some code to generate normally distributed random numbers in ruby? (Note: I answered my own question, but I'll wait a few days before accepting to see if anyone has a better answer.) EDIT: Searching for this, I looked at all pages on SO…
Eponymous
  • 6,143
  • 4
  • 43
  • 43
28
votes
4 answers

scipy.optimize.fmin_l_bfgs_b returns 'ABNORMAL_TERMINATION_IN_LNSRCH'

I am using scipy.optimize.fmin_l_bfgs_b to solve a gaussian mixture problem. The means of mixture distributions are modeled by regressions whose weights have to be optimized using EM algorithm. sigma_sp_new, func_val, info_dict =…
25
votes
6 answers

How do I create a normal distribution in pytorch?

I want to create a random normal distribution with a given mean and std.
dq.shen
  • 351
  • 1
  • 3
  • 6
24
votes
2 answers

Calling rnorm with a vector of means

When I call rnorm passing a single value as mean, it's obvious what happens: a value is generated from Normal(10,1). y <- rnorm(20, mean=10, sd=1) But, I see examples of a whole vector being passed to rnorm (or rcauchy, etc..); in this case, I am…
BBSysDyn
  • 4,389
  • 8
  • 48
  • 63
24
votes
2 answers

How to use boost normal distribution classes?

I'm trying to use boost::normal_distribution in order to generate a normal distribution with mean 0 and sigma 1. The following code doesn't work as some values are over or beyond -1 and 1 (and shouldn't be). Could someont point out what I am doing…
David
  • 2,663
  • 3
  • 24
  • 41
22
votes
4 answers

Generate matrix with iid normal random variables using R

Is there a way to generate a data set with normally distributed random values in R without using a loop? Each entry would represent an independent random variable with a normal distribution.
Crawling Antz
  • 325
  • 1
  • 2
  • 6
1
2 3
85 86