Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to sample a 1-dimensional Gaussian, for this I need to generate random numbers in a certain range which will be used as function input.

The function is $$\mathcal{N}(x|0,1) = \frac{1}{(|2 \pi|)^\frac{1}{2}} \cdot exp(- \frac{1}{2} x^2)$$

Plotting it I get the following result:

plotting gaussian N(x|0,1)

This however does not help me in the decision in which number range I should use, maybe $[-2,2]$? This seems too arbitrary, what is the correct approach here?

In my programming langauge I have a random generator for generating normal variates.

share|cite|improve this question
What do you mean by 'will be used as function input', can you talk more about the specific sampling that you're planning on doing? There are several well-established techniques for generating normal deviates; see, e.g.,… ... – Steven Stadnicki May 29 '12 at 19:55
@StevenStadnicki I have defined the 1-dimensional Gaussian function in my question. In order to sample it, I need input values $x$ in order to get a sample result. That's what I meant. – Mahoni May 29 '12 at 19:57
If you are doing things from scratch, I would suggest the Box-Muller Method, easy to find on the web. Various pieces of software, like Excel, will also do the job, with minimal programming. Calculating the density for various input values $x$ is not too useful, unless you are merely graphing. – André Nicolas May 29 '12 at 19:58
@AndréNicolas I am not doing this from scratch. My programming language has already a function for generating normal variates. – Mahoni May 29 '12 at 20:03
@Mahoni: If your programming language has a function, let it do its stuff. It will presumably not limit outputs to $[-2,2]$, since such events, for $P(|Z|>2)$, though smallish, is non-zero. – André Nicolas May 29 '12 at 20:10
up vote 0 down vote accepted

If this is a standard normal [-2, 2] only contains 95.4 percent of the data [-4, 4} puts it well over 99%. Six sigma would be [-6, 6].

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.