-2

私はパターン認識プロジェクトに取り組んでおり、そこで、指定されたパラメーター(平均および共分散行列)を使用して2次元正規分布をサンプリングしたいと考えています。たとえば、正規分布から100個のサンプルが必要な場合はmvnrnd(mu,sigma,100)、muとsigmaが使用可能であると想定される場所を使用します。しかし、mvnrnd100個の一意のサンプルが返されますが、値が重複している場合でもサンプルが必要です。(100個のサンプルを取得する方法を意味しますが、必ずしも一意の値である必要はありません)どうすればよいですか?

4

2 に答える 2

1

It doesn't say anywhere in the mvnrnd documentation that the samples are guaranteed to be unique, though if your problem is posed in a reasonable manner then this shouldn't be an issue anyways.

Either way, if you're not happy with mvnrnd, this should be equivalent:

% draw 100 samples from a 2D bivariate normal distribution with unit variance and zero mean:
R = randn(2, 100);
% scale by the square root (see http://en.wikipedia.org/wiki/Cholesky_decomposition) of sigma
R1 = chol(sigma)*R;
% offset by the mean
R2 = bsxfun(@plus, R1, mu);
于 2011-12-11T23:21:07.553 に答える
0

機能をチェックしてくださいnormrnd()。正規分布の乱数を生成します。

平均と標準偏差1-by-100を持つ正規分布乱数のベクトルを生成するには、次のステートメントを使用します。musigma

X = normrnd(mu,sigma,[1 100]);
于 2011-12-11T22:42:50.257 に答える