Borrar filtros
Borrar filtros

Why are my Gaussian distributions not properly being generated?

2 visualizaciones (últimos 30 días)
Kevin Nelson
Kevin Nelson el 13 de Sept. de 2022
Respondida: Walter Roberson el 13 de Sept. de 2022
N1 = 1e4;
Y1 = randn(N1,-5,4);
%
N2 = 1e4;
Y2 = randn(N2,5,3);
N3 = 1e4;
Y3 = randn(N3,0,5);
figure(5); clf
histogram(Y3,'Normalization','pdf');
hold on;
%plot(0:Y3-1,1/Y3*ones(size(1:Y3)),'r','LineWidth',2), could not get this
hold off
xlabel('random variable $x$','Interpreter','latex','FontSize',20)
ylabel('Probability density','Interpreter','latex','FontSize',20)
title('Continuous uniform PDF','Interpreter','latex','FontSize',20)
  1 comentario
Kevin Nelson
Kevin Nelson el 13 de Sept. de 2022
I'm supposed to be adding Y1 and Y2 (I was told to add the means (-5 + 5 = 0) and the SD (sqrt(4^2 + 3^2) to get Y3, if that is even right

Iniciar sesión para comentar.

Respuestas (1)

Walter Roberson
Walter Roberson el 13 de Sept. de 2022
Y1 = randn(N1,-5,4);
The numeric parameters to randn() are all sizes so you asked for an array that is N1 by negative 5 by 4.
I suspect that you want
Y1 = randn(1,N1) * 4 - 5
which is multiply by standard deviation and add the mean.

Categorías

Más información sobre Logical en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by