function [cU1,cU2] = clinit(N,C,seed)
%CLINIT     Test cluster initialization (fuzzy case).
%           [U1, U2] = clinit (N,C,seed) returns two initial choices
%           for membership matrices given N samples and C clusters.
%           Random number generator is initialized with seed for
%           each matrix.

% Copyright (c) 1994 by Bogdan R. Kosanovic
% University of Pittsburgh, PA, USA

% get U1
if seed >= 0, rand('seed',seed); end;
cU1 = zeros(C,1);
U1t = zeros(C,N);
for cnt = 1:10
  for k = 1:N
    maxmem = 1;
    for ii = 1:C
      next = maxmem * rand;
      U1t(ii,k) = next;
      maxmem = maxmem - next;
    end;
  end;
  cU1 = cU1 + sum(U1t')';
end;
cU1 = cU1/10;

% get U2
if seed >= 0, rand('seed',seed); end;
cU2 = zeros(C,1);
U2t = zeros(C,N);
for cnt = 1:10
  for k = 1:N
    total = 1;
    for ii = 1:C-1
      next = rand/2;
      nc = C - ii;
      U2t(ii,k) = total * (1 - next^(1/nc));
      total = total - U2t(ii,k);
    end;
    U2t(C,k) = total;
  end;
  cU2 = cU2 + sum(U2t')';
end;
cU2 = cU2/10;
