필터 지우기
필터 지우기

Why do I get different distribution parameters each run?

조회 수: 2 (최근 30일)
MAHMOUD ALZIOUD
MAHMOUD ALZIOUD 2019년 4월 29일
댓글: MAHMOUD ALZIOUD 2019년 4월 30일
Dear All, I have a column vector of 1000 rows, I tried to fit this data into 2_normal mixture distribution using the below code, my question is: Why do I have different parameters every time I run the code, for example the 1st run the mean were (13 and 17), the 2nd run the means became (15 and 16.5)? is there something wrong with my code?
pd = fitgmdist(data, 2);

채택된 답변

Adam Danz
Adam Danz 2019년 4월 29일
The default initial value starting method in fitgmdist() uses a k-means alogorithm that is not deterministic; it uses probability to jump around to different cluster centers (see step #4 in previous link). That leads to converging on slightly different centroids every time the process is run.
To ensure repeatability, record the random number generator seed prior to running the function.
rngState = rng('shuffle');
fitgmdist(...)
% to repeat the same results
rng(rngState)
fitgmdist(...))

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by