📄 samplegaussmixture.m
字号:
function [r mixFlags numVal] = sampleGaussMixture(... mixMeans,mixVars,mixProp,N,mixFlags)% sample [N 1] times from a mixture of gaussians with% means given by mixMeans and variances by mixVars% (each of these should have one value for each component)%% assumes scalar gaussians for now... not hard to change, use% cholesky decomp, or mvrnd%% mixFlags tells which component the item was drawn frommixProp= mixProp/sum(mixProp);r = Inf*ones(N,1);if ~exist('mixFlags','var') mixFlags = Inf*ones(N,1); % sample N from a multinomial for j=1:N mixFlags(j) = find(sample_hist(mixProp',1)); endendfor c=1:length(mixProp) ind = find(mixFlags==c); numVal(c) = length(ind); theseVals = randn(1,numVal(c))*sqrt(mixVars(c)) + mixMeans(c); r(ind)=theseVals; endif any(isinf(r)) error('missing some entries');endreturn;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -