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

1 回表示 (過去 30 日間)
Ted Erdenekhuyag
Ted Erdenekhuyag 2021 年 12 月 16 日
回答済み: Yazan 2021 年 12 月 16 日
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 件のコメント
John D'Errico
John D'Errico 2021 年 12 月 16 日
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 件)

Yazan
Yazan 2021 年 12 月 16 日
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

カテゴリ

Help Center および File ExchangeNumerical Integration and Differentiation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by