# Which input range for sampling a Gaussian distribution

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:

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.

-
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., en.wikipedia.org/wiki/… ... – 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

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].

-