Hello guys, i need help for estimating FAR from this formula can review my code please

mu = 3;
sd = 1;
x= linspace(0,10)
y1 = 1/(2*pi*sd)*exp(-(x-mu).^2/(2*sd^2))
plot(x1,y1);
hold on
mu = 5;
sd = 1;
x2 = linspace(0,10);
y2 = 1/(2*pi*sd)*exp(-(x2-mu).^2/(2*sd^2));
plot(x2,y2);
hold on
plot([1 1]*4, ylim, '--r') % Draw A Red Vertical Line At ‘x=5’
hold off
ylabel('q(x)and p(x)')
xlabel('x')
hold on
x1=linspace(4,10)
trapz(x1,y1)

댓글 수: 2

You have not shown any code. How can we review what we do not see? I'm trying to read your mind, but it is not working.

댓글을 달려면 로그인하십시오.

답변 (1개)

Have you noticed that the distributions defined in your codes are not Gaussian? See the demo below
mu = 3;
sigma = 1;
x = mu-6*sigma:0.05:mu+6*sigma;
dist = 1/sqrt(2*pi*sigma)*exp(-(x-mu).^2/(2*sigma^2));
figure, subplot(1,2,1), plot(x, dist);
x0 = 4;
hold on, xline(x0, 'LineStyle', '--', 'Color', 'r'); hold off
% If you have 'Statistics and Machine Learning Toolbox'
if license('test', 'Statistics_Toolbox')
y1 = 1 - cdf('Normal', 4, mu, sigma);
end
% Otherwise:
x2 = 4:0.05:mu+6*sigma;
dist2 = 1/sqrt(2*pi*sigma)*exp(-(x2-mu).^2/(2*sigma^2));
subplot(1,2,2), plot(x2, dist2);
y2 = trapz(x2, dist2);
if license('test', 'Statistics_Toolbox')
fprintf('Result using the function "cdf" is %g, and using "trapz" is %g', y1, y2)
else
fprintf('Result using the function "trapz" is %g', y2)
end
Result using the function "cdf" is 0.158655, and using "trapz" is 0.158706

카테고리

도움말 센터File Exchange에서 Numerical Integration and Differentiation에 대해 자세히 알아보기

질문:

2021년 12월 16일

답변:

2021년 12월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by