📄 emsamp.m
字号:
function [data,labels] = emsamp(mixture, n)% EMSAMP Generates a sample of N data points from MoG in mixture% % Description% DATA = EMSAMP(MIXTURE,N) generates a data matrix that has N rows% (n data points) and each point is drawn from the MoG MIXTURE % [DATA, LABELS] = EMSAMP(MIXTURE,N) generates along with the data% a labeling from which gaussian in the mixture a point was% generated. % Determine number to sample from each component. Now i am not sure% if this function is wokring properly?????% % SEE also VSAMPlabels=zeros(n,1);priors = rand(1,n);% Pre-allocate data arraydata = zeros(n, mixture.dim);cum_prior = 0; % Cumulative sum of priorstotal_samples = 0; % Cumulative sum of number of sampled pointsfor j = 1:mixture.num_clus num_samples = sum(priors >= cum_prior & ... priors < cum_prior + mixture.priors(j)); kappa = mixture.kappas(j); data(total_samples+1:total_samples+num_samples, :) = ... vsamp((mixture.centers(j, :))', kappa, num_samples); labels(total_samples+1:total_samples+num_samples) = j; cum_prior = cum_prior + mixture.priors(j); total_samples = total_samples + num_samples;end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -