def plot_posterior(self, samples, bins=100, alpha=None, color=None, label=None, range=None, normed=True):
        """
        Function for plotting posterior histogram.

        parameters
        ----------
        samples: (1D array)
            an array of accepted exponents during the MCMC algorithm.
        
        bins: (int)
            number of bins used for the histogram (default: 100).
        
        alpha: (0<=float<=1)
            transparency of the histogram.

        color: (str)
            color of the histogram.
        
        label: (str)
            label of the histogram.
        
        range: (tuple)
            range of histogram's X axis.
        
        normed: (bool)
            whether the histogram is normalized or not (default: True)

        returns
        -------

        None.

        """

        check(type(samples)==np.ndarray,
                'samples input must be a 1-dimensional array')
        
        check(len(samples)>=100,
                'your samples array length = %s, your posterior array is likely multidimensional. Posterior from bayes function is returned multidimensional. Try indexing. Eg. fit.gamma_posterior[0].' %len(samples))


        plt.hist(samples, bins, alpha=alpha, color=color,
                 label=label, range=range, normed=normed)
        return
    def plot_fit(self,
                 gamma_mean,
                 data_label=None,
                 data_color=None,
                 edge_color=None,
                 fit_color=None,
                 scatter_size=10,
                 line_width=1,
                 fit=True,
                 log=True,
                 xmin=None):
        """
        Function for plotting the date as a power law distribution on a log log scale
        along with the best fit.

        parameters
        ----------

        gamma_mean: (float)
            Final exponent used to generate the best fit curve. For best results
            use the mean of posterior samples.

        data_label: (str)
            curve label.

        data color: (str)
            color of the data scatter plot.

        edge_color: (str)
            color of the scatter marker edge.

        fit_color: (str)
            color of the best fit curve.
        
        scatter_size: (int or float)
            scatter marker size.

        line_width: (int or float)
            width of the best fit curve.

        fit: (bool)
            Whether to plot the best fit curve or not (default True).

        log: (bool)
            Whether to plot in the log scale or not (default True).

        returns
        -------

        None.

        """

        check(isinstance(gamma_mean,(int,float)) and type(gamma_mean)!=bool,
                'gamma_mean input must be int or float')

        check(gamma_mean > 1.0,
                'gamma_mean input = %s, must be > 1.0' % gamma_mean)

        check(isinstance(data_label,str) or data_label==None,
                'data_label must be a string')

        check(isinstance(scatter_size,(int,float)) and type(scatter_size)!=bool,
                'scatter_size must be int or float')
        
        check(scatter_size>0,
                'scatter_size input = %s, must be > 0' % scatter_size)

        check(isinstance(line_width,(int,float)) and type(line_width)!=bool,
                'line_width must be int or float')

        check(line_width>0,
                'line_width input = %s, must be > 0' % line_width)

        check(isinstance(fit,bool),
                'fit input must be bool. Default is True. Choose false if do not want to plot a fit')

        check(isinstance(log,bool),
                'log input must be bool. Default is True. Choose false if want to plot on regular scale')

        check((isinstance(xmin,(int,float)) and type(xmin)!=bool) or xmin==None,
                'xmin input must be int,float or None')
        if xmin!=None:
            check(xmin>=1,
                    'xmin input = %s, must be > 1 if not None' % xmin)
        

        if self.discrete:
            unique, counts = np.unique(self.data, return_counts=True)
            frequency = counts / np.sum(counts)
        else:
            yx = plt.hist(self.data, bins=1000, normed=True)
            plt.clf()
            counts_pre = (yx[0])
            unique_pre = ((yx[1])[0:-1])
            unique = unique_pre[counts_pre != 0]
            frequency = counts_pre[counts_pre != 0]
            # frequency = counts / np.sum(counts)
        X, Y = self.powerlawpdf(gamma_mean, xmin)
        if log:
            plt.xscale('log')
            plt.yscale('log')
        plt.scatter(unique, frequency, s=scatter_size,
                    color=data_color, edgecolor=edge_color,label=data_label)
        if fit:
            plt.plot(X, Y, color=fit_color, linewidth=line_width)
        return
    def _input_checks(self):
        """
        Validate parameters passed to the bayes constructor.
        """

        check(len(self.data) > 0,
                'data input length = %s, must be > 0' % len(self.data))

        check(self.data.dtype=='int64' or self.data.dtype=='float64',
                'Your data contains non-numbers, data input must only contain positive integers or floats')

        check(np.sum(self.data<=0)==0,
                "your data input contains non-positive values, all values must be positive")

        check(isinstance(self.mixed,int) and type(self.mixed)!=bool,
                'mixed input must be int')
   
        check(self.mixed>=1,
                'mixed input = %s, must be >=1' % self.mixed)

        check(len(self.range)==2,
                'gamma_range input length = %s, must be of length 2' % len(self.range))

        check(isinstance(self.range[0],(int,float)),
                'gamma_range input must contain floats or ints')
        
        check(isinstance(self.range[1],(int,float)),
                'gamma_range input must contain floats or ints')

        check(self.range[0]>1,
                'gamma_range[0] = %s,lower bound of gamma range must be > 1' %self.range[0])

        check(self.range[0]<self.range[1],
                'lower bound of gamma range must be smaller than the upper bound') 

        check(isinstance(self.discrete,bool),
                'discrete input must be bool. Default is True. Choose False if data is continuous') 
        
        check(self.prior=="jeffrey" or self.prior=="flat",
                'unrecognized prior. Default is "jeffrey". Choose "flat" if perfered')

        check(isinstance(self.niters,int),
                'niters input must be int')
        
        check(self.niters>=100,
                'niters = %s, must be more than or equal to 100 for best performance')

        check(isinstance(self.burn,int),
                'burn_in input must be int')

        check(self.burn>=100,
                'burn_in = %s, must be more than or equal to 100 for best performance')
        
        check(isinstance(self.sigma,list),
                'sigma input must be a list of length 2')

        check(len(self.sigma)==2,
                'sigma input length = %s, must be of length 2' % len(self.sigma))

        check(type(self.sigma[0])!=bool and type(self.sigma[1])!=bool,
                'sigma input is bool, must be int or float')

        check(isinstance(self.sigma[0],(int,float)),
                'sigma input must contain ints or floats')
        
        check(isinstance(self.sigma[1],(int,float)),
                'sigma input must contain ints or floats') 

        check(self.sigma[0]>0,
                'sigma input = %s, must be > 0' % self.sigma)

        check(self.sigma[1]>0,
                'sigma input = %s, must be > 0' % self.sigma)

        check(isinstance(self.sigma_burn,list),
                'sigma_burn input must be a list of length 2')

        check(len(self.sigma_burn)==2,
                'sigma_burn input length = %s, must be of length 2' % len(self.sigma_burn))

        check(type(self.sigma_burn[0])!=bool and type(self.sigma_burn[1])!=bool,
                'sigma_burn input is bool, must be int or float')

        check(isinstance(self.sigma_burn[0],(int,float)),
                'sigma_burn input must contain floats')
        
        check(isinstance(self.sigma_burn[1],(int,float)),
                'sigma_burn input must contain floats') 

        check(self.sigma_burn[0]>0,
                'sigma_burn input = %s, must be > 0' % self.sigma_burn)

        check(self.sigma_burn[1]>0,
                'sigma_burn input = %s, must be > 0' % self.sigma_burn)

        check(isinstance(self.fit,bool),
                'fit input must be bool. Default is True. Choose False if do not want to fit') 
    def _xminmax_check(self):

        check(isinstance(self.xmin,(int,float)),
                'Xmin must be int or float')

        check(type(self.xmin)!=bool,
                'Xmin is bool, must be int or float')

        check(self.xmin>0, 
                'Xmin input = %s, must be > 0' % self.xmin)
        
        check(isinstance(self.xmax,(int,float)),
                'Xmax must be int or float')
        
        check(type(self.xmax)!=bool,
                'Xmaxn is bool, must be int or float')

        check(self.xmax>self.xmin,
                'xmin is larger than xmax, must be xmin<xmax'
                )
    def _input_checks(self):

        check(len(self.data) > 0,
                'data input length = %s, must be > 0' % len(self.data))

        check(self.data.dtype=='int64' or self.data.dtype=='float64',
                'Your data contains non-numbers, data input must only contain positive integers or floats')

        check(np.sum(self.data<=0)==0,
                "your data input contains non-positive values, all values must be positive")

        check(isinstance(self.discrete,bool),
                'discrete input must be bool. Default is True. Choose False if data is continuous') 

        check(len(self.initial_guess)==3,
                'length of initial_guess input = %s, length must be 3' %len(self.initial_guess))

        check(isinstance(self.initial_guess[0],(int,float)) and isinstance(self.initial_guess[1],(int,float)),
                'lower [0] and upper [1] guess range inputs must be int or float')

        check(isinstance(self.initial_guess[2],(int)),
                'number of guesses [2] range must be int')

        check(self.initial_guess[0]>=1,
                'lower guess range initial_guess[0] = %s, must be > 1' %self.initial_guess[0])

        check(self.initial_guess[0]<self.initial_guess[1],
                'lower guess range initial_guess[0] must be lower than upper guess range initial_guess[1]')

        check(self.initial_guess[2]>0,
                'number of guesses initial_guess[2] = %s, must be > 0' %self.initial_guess[2])