random
가우스 혼합 분포의 확률 변량
설명
예제
확률 변량 생성하기
gmdistribution
객체를 만들고 확률 변량을 생성합니다.
두 개의 이변량 가우스 혼합 분포 성분으로 구성된 분포 파라미터(평균 및 공분산)를 정의합니다.
mu = [1 2;-3 -5];
sigma = [1 1]; % shared diagonal covariance matrix
gmdistribution
객체는 gmdistribution
함수를 사용하여 생성할 수 있습니다. 기본적으로, 이 함수는 성분의 비율이 동일하도록 혼합합니다.
gm = gmdistribution(mu,sigma)
gm = Gaussian mixture distribution with 2 components in 2 dimensions Component 1: Mixing proportion: 0.500000 Mean: 1 2 Component 2: Mixing proportion: 0.500000 Mean: -3 -5
1,000개의 확률 변량을 생성합니다.
rng('default'); % For reproducibility [Y,compIdx] = random(gm,1000);
compIdx(i)
는 i
번째 확률 변량 Y(i,:)
를 생성하는 데 사용되는 혼합 성분을 나타냅니다. Component
1
에 의해 생성된 확률 변량의 개수를 계산합니다.
numIdx1 = sum(compIdx == 1)
numIdx1 = 512
random
은 gm
의 혼합 비율이 같으므로 Component
1
을 사용하여 확률 변량의 약 절반을 생성합니다.
scatter
를 사용하여 생성된 확률 변량을 플로팅합니다.
scatter(Y(:,1),Y(:,2),10,'.') % Scatter plot with points of size 10
난수 생성기 재설정하기
난수 생성기를 재설정하여 동일한 확률 변량을 생성합니다.
두 개의 이변량 가우스 혼합 성분으로 구성된 분포 파라미터(평균, 공분산 및 혼합 비율)를 정의합니다.
p = [0.4 0.6]; % Mixing proportions mu = [1 2;-3 -5]; % Means sigma = cat(3,[2 .5],[1 1]) % Covariances 1-by-2-by-2 array
sigma = sigma(:,:,1) = 2.0000 0.5000 sigma(:,:,2) = 1 1
cat
함수는 세 번째 배열 차원을 따라 공분산을 결합합니다. 정의된 공분산 행렬은 대각 행렬입니다. sigma(1,:,i)
는 성분 i
의 공분산 행렬의 대각 요소를 포함합니다.
gmdistribution
객체는 gmdistribution
함수를 사용하여 생성할 수 있습니다.
gm = gmdistribution(mu,sigma);
난수 생성기의 현재 상태를 저장한 다음, gm
을 사용하여 확률 변량을 생성합니다.
s = rng; r = random(gm)
r = 1×2
-1.1661 -7.2588
난수 생성기의 상태를 s
로 복원한 다음, gm
을 사용하여 확률 변량을 생성합니다. 값이 이전과 같습니다.
rng(s); r1 = random(gm)
r1 = 1×2
-1.1661 -7.2588
입력 인수
gm
— 가우스 혼합 분포
gmdistribution
객체
가우스 혼합 분포(가우스 혼합 모델 또는 GMM이라고도 함)로, gmdistribution
객체로 지정됩니다.
gmdistribution
또는 fitgmdist
를 사용하여 gmdistribution
객체를 생성할 수 있습니다. gmdistribution
객체는 gmdistribution
함수를 사용하여 분포 파라미터를 지정하여 생성할 수 있습니다. fitgmdist
함수를 사용해, 고정된 개수의 성분이 주어진 경우에 gmdistribution
모델을 데이터에 피팅합니다.
n
— 확률 변량의 개수
1 (디폴트 값) | 양의 정수
생성할 확률 변량의 개수로, 양의 정수로 지정됩니다.
데이터형: single
| double
출력 인수
버전 내역
R2007b에 개발됨
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)