필터 지우기
필터 지우기

Difference between lhsnorm and normrnd

조회 수: 5 (최근 30일)
Ankush Kumar Mishra
Ankush Kumar Mishra 2022년 4월 20일
댓글: Ankush Kumar Mishra 2022년 4월 20일
I am trying to understand the differnce between lhsnorm and normrnd. I generate two samples using same mean and std butthese metods are giving very different sample? The code is below
n = 50; % number of observations
noise_std = .02; % standard deviation of noise
d = 30;
mu = 0*ones(d,1);
sd = 0.2*ones(d,1);
sigma = 0.2*eye(d);
xtrain = lhsnorm(mu,sigma,n);
xtrain1 = normrnd(0,0.2,n,d);
I expected xtrain and xtrain1 to me similar but it is not. 30 features all with 0 mean and 0.2 std. Plese let me know if i am making mistake with lhsnorm.

채택된 답변

Paul
Paul 2022년 4월 20일
The doc page for lhsnorm is surprisingly sparse. But it does talk about the multi-variable normal distribution, in which case sigma is usally the covariance of the distribution. So for xtrain try
Sigma = 0.2^2 * eye(d)
xtrain = lhsnorm(mu,Sigma,n);
The sigma input to normrnd is the standard deviation, as you've done in the code.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by