Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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 commentaires
John D'Errico
John D'Errico le 16 Déc 2021
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.

Connectez-vous pour commenter.

Réponses (1)

Yazan
Yazan le 16 Déc 2021
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

Catégories

En savoir plus sur Numerical Integration and Differentiation dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by