This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SocketServer, subprocess, sys | |
from threading import Thread | |
from TwitterAPI import TwitterAPI | |
import json, unidecode | |
api = TwitterAPI(consumer_key, consumer_secret, access_token_key, access_token_secret) | |
HOST = 'localhost' | |
PORT = 9999 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hypotheses = [[.8, .2], | |
[.5,.5], | |
[.2,.8]] | |
# Notice how we swapped out the Beta for | |
# a Dirichlet. The only difference is we | |
# now pass a list of counts to the pdf | |
# function. We'll get to why in a bit. | |
pdf_score = np.array([ss.dirichlet.pdf(hypothesis, [1+1+2, 1+5+3]) for hypothesis in hypotheses]) | |
probabilities = pdf_score/pdf_score.sum() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The walnut/almond mix ratios we have hypothesized | |
hypotheses = [[.8, .2], | |
[.5,.5], | |
[.2,.8]] | |
# Evaluate the pdf for each hypothesis | |
# Note that we only evaluate the hypothesis | |
# for one nut. If it's 80% we know the | |
# other must be 20%. | |
pdf_score = np.array([ss.beta.pdf(hypothesis[0], 1+1, 1+5) for hypothesis in hypotheses]) |
OlderNewer