Integration of shifted Gaussian Distribution function giving incorrect answer

1 view (last 30 days)
When I integrate the standard distribution function with shifting factor mu = 0 and sigma = .01, I get the expected result of 1:
p1 = @(x) gaussian_const .* exp(-((x)./(2.*sigma)).^2);
int = integral(p1,-Inf,Inf)
but if I make mu a large enough number or shift the function right or left, the integration returns a very small number. For example mu = 5,
p1 = @(x) gaussian_const .* exp(-((x-5)./(2.*sigma)).^2);
int = integral(p1,-Inf,Inf)
returns a near-zero value. Smaller values of mu, for example 1 or 2, still give the correct value of 1; but once I try 3 it returns very small number again.
Larger sigma values also seem to increase the range for what mu can be before I get zeros as answers. Any thoughts on why this is happening? I'm using this function to approximate the Dirac delta function, so very small sigma values are important.

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!