emsamp.m

来自「wekaUT是 university texas austin 开发的基于wek」· M 代码 · 共 34 行

M
34
字号
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 + =
减小字号Ctrl + -
显示快捷键?