def mean(self,chrom=''):
        """Return the mean of wig
        
        Parameters:
        1. chrom: if '', return the max of the whole wig; otherwise, return the maxi of the chrom
        """
        
        if chrom:
            n=self.length(chrom=chrom)
            try:
                return 1.0*sum(self[chrom][1])/n
            except (KeyError, IndexError, ZeroDivisionError):
                return None
        else:
            cumsum=0
            cumcnt=0
            for chrom in self.get_chroms():
                try:
                    cumsum+=sum(self[chrom][1])
                    cumcnt+=self.length(chrom=chrom)
                except (KeyError, IndexError):
                    pass
            
            try: 
                return 1.0*cumsum/cumcnt
            except ZeroDivisionError:
                return None
dataset/ETHPy150Open taoliu/taolib/Assoc/inout.py/Wig.mean/original