def Likelihood(self, data, hypo): """Computes the likelihood of the data under the hypothesis. hypo: data: """ std = 30 meanx, meany = hypo x, y = data like = thinkbayes2.EvalNormalPdf(x, meanx, std) like *= thinkbayes2.EvalNormalPdf(y, meany, std) return like
def RenderPdf(mu, sigma, n=101): """Makes xs and ys for a normal PDF with (mu, sigma). n: number of places to evaluate the PDF """ xs = numpy.linspace(mu - 4 * sigma, mu + 4 * sigma, n) ys = [thinkbayes2.EvalNormalPdf(x, mu, sigma) for x in xs] return xs, ys
def Likelihood(self, data, hypo): """Computes the likelihood of the data under the hypothesis. hypo: the percentage of voters who you hypothesize to favor your candidate data: tuple (mean, standard deviation, measurement) """ mean, std_dev, measurement = data error = measurement - hypo likelihood = thinkbayes2.EvalNormalPdf(error, mean, std_dev) return likelihood
def Likelihood(self, data, hypo): '''Computes the likelihood of the data under the hypothesis data: tuple of (number of sensing, number of intuitive) hypo: mu and sigma pair describing the distribution of learning styles''' mu, sigma = hypo x = data like = thinkbayes2.EvalNormalPdf(x, mu, sigma) return like
def Likelihood(self, data, hypo): """Computes the likelihood of the data under the hypothesis. hypo: fraction of the population that supports your candidate data: poll results """ bias, std, result = data error = result - hypo like = thinkbayes2.EvalNormalPdf(error, bias, std) return like
def Likelihood(self, data, hypo): """Computes the likelihood of the data under the hypothesis. hypo: x, y data: x, y """ measured_x, measured_y = data actual_x, actual_y = hypo error_x = measured_x - actual_x error_y = measured_y - actual_y prob_x = thinkbayes2.EvalNormalPdf(error_x, 0, 30) prob_y = thinkbayes2.EvalNormalPdf(error_y, 0, 30) like = prob_x * prob_y return like
def Likelihood(self, data, hypo): ''' Likelihood of the data under the hypothesis. hypo: fraction of the population data: poll results ''' bias, std, result = data error = result - hypo like = thinkbayes2.EvalNormalPdf(error, bias, std) return like
def Likelihood(self, data, hypo): """Computes the likelihood of the data under the hypothesis. hypo: data: """ a_hypo = hypo mean, std, measurement = data e_hypo = measurement - a_hypo like = thinkbayes2.EvalNormalPdf(e_hypo, mean, std) return like
def Likelihood(self, data, hypo): """ Calculate the likelihood of a hypo given the data data: [(Timestamp, 12.142122), ...] pandas dataframe of records in the form of (date, record in mph) tuples hypo: (alpha, beta, sigma) """ alpha, beta, sigma = hypo total_likelihood = 1 for i, row in enumerate(data.values): date = row[1].value # ms measured_mph = row[0] predicted_mph = alpha + beta * date error = measured_mph - predicted_mph total_likelihood *= thinkbayes2.EvalNormalPdf(error, mu=0, sigma=sigma) return total_likelihood