def MakeData(self, K=3, Nperclass=1000):
   ''' Creates simple toy dataset for testing.
       Simple 3 component data with eye covar and distinct, well-sep means
         mu0 = [-10, -10]
         mu1 = [0, 0]
         mu2 = [10, 10]
   '''
   PRNG = np.random.RandomState(8675309)
   # Means:  [-10 -10; 0 0; 10 10]
   Mu = np.zeros((3,2))
   Mu[0] = Mu[0] - 10
   Mu[2] = Mu[2] + 10
   # Covariances: identity
   Sigma = np.eye(2)    
   # Generate data from K components, each with Nperclass examples
   self.TrueResp = np.zeros((K*Nperclass,K))
   Xlist = list()
   for k in range(K):
     Xcur = mvnrand(Mu[k], Sigma, Nperclass, PRNG)    
     Xlist.append(Xcur)
     self.TrueResp[k*Nperclass:(k+1)*Nperclass, k] = 1.0
   X = np.vstack(Xlist)
   self.Data = XData(X=X)
   self.Mu = Mu
   assert np.abs(self.TrueResp.sum() - self.Data.nObs) < 1e-2
Esempio n. 2
0
    def MakeData(self, K=3, Nperclass=1000):
        ''' Create simple toy XData with K components, add as attribute to self

        Simple 3 component data with eye covar and distinct, well-sep means
        mu0 = [-10, -10]
        mu1 = [0, 0]
        mu2 = [10, 10]
    '''
        Mu = np.zeros((3, 2))
        Mu[0] = Mu[0] - 10
        Mu[2] = Mu[2] + 10
        Sigma = np.eye(2)
        self.TrueResp = np.zeros((K * Nperclass, K))
        self.DupResp = np.zeros((K * Nperclass, 2 * K))
        Xlist = list()
        for k in range(K):
            Xcur = mvnrand(Mu[k], Sigma, Nperclass)
            Xlist.append(Xcur)
            self.TrueResp[k * Nperclass:(k + 1) * Nperclass, k] = 1.0
            start = k * Nperclass
            stop = (k + 1) * Nperclass
            half = 0.5 * (start + stop)
            self.DupResp[start:half, k] = 1.0
            self.DupResp[half:stop, K + k] = 1.0
        X = np.vstack(Xlist)
        self.Data = XData(X=X)
        self.Mu = Mu
        assert np.abs(self.TrueResp.sum() - self.Data.nObs) < 1e-2
        assert np.abs(self.DupResp.sum() - self.Data.nObs) < 1e-2
  def MakeData(self, K=3, Nperclass=1000):
    ''' Create simple toy XData with K components, add as attribute to self

        Simple 3 component data with eye covar and distinct, well-sep means
        mu0 = [-10, -10]
        mu1 = [0, 0]
        mu2 = [10, 10]
    '''
    Mu = np.zeros((3,2))
    Mu[0] = Mu[0] - 10
    Mu[2] = Mu[2] + 10
    Sigma = np.eye(2)    
    self.TrueResp = np.zeros((K*Nperclass,K))
    self.DupResp = np.zeros((K*Nperclass, 2*K))
    Xlist = list()
    for k in range(K):
      Xcur = mvnrand( Mu[k], Sigma, Nperclass)    
      Xlist.append(Xcur)
      self.TrueResp[k*Nperclass:(k+1)*Nperclass, k] = 1.0
      start = k*Nperclass
      stop = (k+1)*Nperclass
      half = 0.5*(start + stop)      
      self.DupResp[start:half, k] = 1.0
      self.DupResp[half:stop, K+k] = 1.0
    X = np.vstack(Xlist)
    self.Data = XData(X=X)
    self.Mu = Mu
    assert np.abs(self.TrueResp.sum() - self.Data.nObs) < 1e-2
    assert np.abs(self.DupResp.sum() - self.Data.nObs) < 1e-2
Esempio n. 4
0
 def MakeData(self, K=3, Nperclass=1000):
     ''' Creates simple toy dataset for testing.
     Simple 3 component data with eye covar and distinct, well-sep means
       mu0 = [-10, -10]
       mu1 = [0, 0]
       mu2 = [10, 10]
 '''
     PRNG = np.random.RandomState(8675309)
     # Means:  [-10 -10; 0 0; 10 10]
     Mu = np.zeros((3, 2))
     Mu[0] = Mu[0] - 10
     Mu[2] = Mu[2] + 10
     # Covariances: identity
     Sigma = np.eye(2)
     # Generate data from K components, each with Nperclass examples
     self.TrueResp = np.zeros((K * Nperclass, K))
     Xlist = list()
     for k in range(K):
         Xcur = mvnrand(Mu[k], Sigma, Nperclass, PRNG)
         Xlist.append(Xcur)
         self.TrueResp[k * Nperclass:(k + 1) * Nperclass, k] = 1.0
     X = np.vstack(Xlist)
     self.Data = XData(X=X)
     self.Mu = Mu
     assert np.abs(self.TrueResp.sum() - self.Data.nObs) < 1e-2
 def MakeData(self, nObsC=200):
   if self.obsM is None:
     return
   XList = list()
   np.random.seed(505)
   for k in range(self.obsM.K):
     Sigma = self.obsM.get_covar_mat_for_comp(k)
     mu = self.obsM.get_mean_for_comp(k)
     Xcur = mvnrand(mu, Sigma, nObsC)
     XList.append(Xcur)
   X = np.vstack(XList)
   self.nObsC = nObsC
   self.Data = XData(X=X)  
Esempio n. 6
0
 def MakeData(self, nObsC=200):
     if self.obsM is None:
         return
     XList = list()
     np.random.seed(505)
     for k in range(self.obsM.K):
         Sigma = self.obsM.get_covar_mat_for_comp(k)
         mu = self.obsM.get_mean_for_comp(k)
         Xcur = mvnrand(mu, Sigma, nObsC)
         XList.append(Xcur)
     X = np.vstack(XList)
     self.nObsC = nObsC
     self.Data = XData(X=X)