Mercurial > hg > camir-aes2014
comparison toolboxes/FullBNT-1.0.7/netlab3.3/dem2ddat.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function [data, c, prior, sd] = dem2ddat(ndata) | |
2 %DEM2DDAT Generates two dimensional data for demos. | |
3 % | |
4 % Description | |
5 % The data is drawn from three spherical Gaussian distributions with | |
6 % priors 0.3, 0.5 and 0.2; centres (2, 3.5), (0, 0) and (0,2); and | |
7 % standard deviations 0.2, 0.5 and 1.0. DATA = DEM2DDAT(NDATA) | |
8 % generates NDATA points. | |
9 % | |
10 % [DATA, C] = DEM2DDAT(NDATA) also returns a matrix containing the | |
11 % centres of the Gaussian distributions. | |
12 % | |
13 % See also | |
14 % DEMGMM1, DEMKMEAN, DEMKNN1 | |
15 % | |
16 | |
17 % Copyright (c) Ian T Nabney (1996-2001) | |
18 | |
19 input_dim = 2; | |
20 | |
21 % Fix seed for reproducible results | |
22 randn('state', 42); | |
23 | |
24 % Generate mixture of three Gaussians in two dimensional space | |
25 data = randn(ndata, input_dim); | |
26 | |
27 % Priors for the three clusters | |
28 prior(1) = 0.3; | |
29 prior(2) = 0.5; | |
30 prior(3) = 0.2; | |
31 | |
32 % Cluster centres | |
33 c = [2.0, 3.5; 0.0, 0.0; 0.0, 2.0]; | |
34 | |
35 % Cluster standard deviations | |
36 sd = [0.2 0.5 1.0]; | |
37 | |
38 % Put first cluster at (2, 3.5) | |
39 data(1:prior(1)*ndata, 1) = data(1:prior(1)*ndata, 1) * 0.2 + c(1,1); | |
40 data(1:prior(1)*ndata, 2) = data(1:prior(1)*ndata, 2) * 0.2 + c(1,2); | |
41 | |
42 % Leave second cluster at (0,0) | |
43 data((prior(1)*ndata + 1):(prior(2)+prior(1))*ndata, :) = ... | |
44 data((prior(1)*ndata + 1):(prior(2)+prior(1))*ndata, :) * 0.5; | |
45 | |
46 % Put third cluster at (0,2) | |
47 data((prior(1)+prior(2))*ndata +1:ndata, 2) = ... | |
48 data((prior(1)+prior(2))*ndata+1:ndata, 2) + c(3, 2); |