source: prextra/genriver.m @ 46

Last change on this file since 46 was 5, checked in by bduin, 14 years ago
File size: 1.3 KB
RevLine 
[5]1%GENRIVER Generate 2D 2-class River data
2%
3%               A = GENRIVER(N,L,S)
4%
5% INPUT
6%   N    Number of objects in each of the classes (default: [50 50])
7%   L    Length of the river, default: L = 1 (i.e. 2 bends)
8%   S    Width of uniform class distribution on the river borders,
9%        default: S = 1;
10%
11% OUTPUT
12%   A    Generated dataset
13%
14% Generate a separable 'bending river'-like 2D dataset of two classes.
15% Class priors are equal.
16%
17% EXAMPLE
18%  repset = genriver([10 10],4);
19%  trainset = genriver([],4);
20%  w = proxm(repset,'d');
21%  v = w*fisherc(trainset*w);
22%  figure; scatterd(trainset); plotc(v)
23%
24% SEE ALSO
25% DATASETS, PRDATASETS
26
27% Copyright: A. Harol, R.P.W. Duin, r.p.w.duin@prtools.org
28% Faculty EWI, Delft University of Technology
29% P.O. Box 5031, 2600 GA Delft, The Netherlands
30
31function a = genriver(N,len,s,d)
32
33        prtrace(mfilename);
34       
35        if nargin < 4, d = 0; end
36        if nargin < 3, s = 1; end
37        if nargin < 2 | isempty(len), len = 1; end
38        if nargin < 1 | isempty(N), N = [50 50]; end
39
40        p = [0.5 0.5];
41        N = genclass(N,p);     
42        x1=len*2*pi*rand(1,N(1));
43        x2=sin(x1)+(s*rand(size(x1)))+d;
44        d1 = dataset([x1',x2'],ones(size(x1')));
45        x3=len*2*pi*rand(1,N(2));
46        x4 = sin(x3)+(-s+s*rand(size(x3)))-d;
47        d2 = dataset([x3',x4'],2*ones(size(x3')));
48        a = setprior([d1;d2],p);
49       
50return
Note: See TracBrowser for help on using the repository browser.