def generate(self,imgdirs,numcodes=128,sz=(11,11),imgs_per_dir=50,img_layout=(8,16),padding=0, verbose=True):
        if( numcodes != img_layout[0]*img_layout[1]):
            warnings.warn("Numcodes must match the size of image layout.")
            return None

        self.mPadding = padding
        self.mLayout = img_layout
        self.mNumCodes = numcodes
        self.mPatchSize = sz
        rawFeatures = np.zeros(sz[0]*sz[1])#fakeout numpy so we can use vstack
        for path in imgdirs:
            fcount = 0
            files = []
            for ext in IMAGE_FORMATS:
                files.extend(glob.glob( os.path.join(path, ext)))
            nimgs = min(len(files),imgs_per_dir)
            for i in range(nimgs):
                infile = files[i]
                if verbose:
                    print(path+" "+str(i)+" of "+str(imgs_per_dir))
                    print "Opening file: " + infile
                img = Image(infile)
                newFeat = self._getPatches(img,sz)
                if verbose:
                    print "     Got " + str(len(newFeat)) + " features."
                rawFeatures = np.vstack((rawFeatures,newFeat))
                del img
        rawFeatures = rawFeatures[1:,:] # pop the fake value we put on the top
        if verbose:
            print "=================================="
            print "Got " + str(len(rawFeatures)) + " features "
            print "Doing K-Means .... this will take a long time"
        self.mCodebook = self._makeCodebook(rawFeatures,self.mNumCodes)
        self.mCodebookImg = self._codebook2Img(self.mCodebook,self.mPatchSize,self.mNumCodes,self.mLayout,self.mPadding)
        self.mCodebookImg.save('codebook.png')
Test for normality of standardized residuals.
dataset/ETHPy150Open sightmachine/SimpleCV/SimpleCV/Features/BOFFeatureExtractor.py/BOFFeatureExtractor.generate--crossover with--dataset/ETHPy150Open statsmodels/statsmodels/statsmodels/tsa/statespace/mlemodel.py/MLEResults.test_normality