Expected value of Bernoulli with probability of success Gaussian distributed I have a circle with centre $(0,0)$. I am generating Matlab code to include $N$ neurons in a neural network. The probability of including individual neurons in a network decays exponentially with distance, $d$, from the centre. So the probability of a neuron being included is Gaussian with distance, i.e. $\frac{1}{\sqrt{2\pi}\sigma}e^{-d^2/r^2}$, where $r$ is the radius of the Gaussian (I'm not dealing with truncated Gaussians at this point). Once the probability of including the neuron has been determined, I then generate a uniform random variable on $[0,1]$, & if the value is less than the bound given by the Gaussian probability it's included, otherwise it's not. 
However, since I want the expected number of included neurons at the end of this process to be $N$, I need to scale the bound, but I am not sure how to do this to give a final value of $N$. It's complicated by the fact it's in multiple dimensions, but even starting with a single dimension would be great. 
Sorry if this is confusing. I am happy to explain it in more detail if required. Thank you in advance for your help. 
 A: I think I understand what you want. Here is a one-dimensional version.
Make a sketch as follows: (a) Draw a standard normal curve (it has
height about .4 in the middle, inflection points at $\pm 1$,
and nearly touches the x-axis at $\pm 3.$
(b) Superimpose a rectangle with base extending between $\pm 2$
and 1 unit it height.
You will generate a candidate neuron randomly and uniformly
in the interval $(-2,2).$ At its location, draw a vertical line
up to the top of the box. You accept the candidate neuron precisely if a point at random on this line is beneath the normal curve. 
If you want N accepted candidates, you need to generate M > N
candidates. You get M by multiplying N by the ratio of the
area of the box to the area under the curve within the box.
A program in R to do this is as follows. I picked N = 1000
and almost always get a number of accepted candidates within about 30
of 1000, usually much closer.
 a.gau = diff(pnorm(c(-b,b)))    # Area under Gaussian
 b = 2   # Box has base twice b  # Area of box 2*b
 N = 1000                        # Desired Nr. accepted
 M = N*2*b/a.gau                 # Candidates required
 x = runif(M, -b,b)              # Location of candidate    
 acc = (runif(M) < dnorm(x))     # M-vec has T if accepted
 x.acc = x[acc]                  # Retain accepted candidates
 length(x.acc)                   # actual number accepted
 hist(x.acc)                     # hist of accepted cand.

In the code 'runif(M, -b, b)' means pick M random points
between -b and b; 'runif(M)' means pick M random points between 0
and 1 (the default boundaries); and 'dnorm(x)' is the height
of the normal curve above point x.
You could get by with fewer candidate points if more are accepted.
It turns out you can double the height of the normal curve
and still be within the box. Modified code to do this is shown
below. (Altered lines have ##.)
 a.gau = diff(pnorm(c(-b,b)))    # Area under Gaussian
 b = 2   # Box has base twice b  # Area of box 2*b
 N = 1000                        # Desired Nr. accepted
 M = N*b/a.gau                   ## Candidates required
 x = runif(M, -b,b)              # Location of candidate    
 acc = (runif(M) < 2*dnorm(x))   ## M-vec has T if accepted
 x.acc = x[acc]                  # Retain accepted candidates
 length(x.acc)                   # actual number accepted
 hist(x.acc)                     # hist of accepted cand.

Note:  On the line, it would be easier just to sample directly
from the normal distribution. But I believe the acceptance-rejection
method with a gaussian envelope is better in 2-D. In 2-D you
will need x and y coordinates to pick candidate points. If this
is at all what you had in mind in your question, I suppose you
can adapt the idea of using ratios of areas to ratios of volumes
for your project.
