This file contains 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 random | |
#number of games to play | |
n = 5 | |
#number of correct guesses on first guess | |
correct = 0 | |
# run simulations | |
for i in range(n): | |
print 'cycle %i' % i |
This file contains 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
"""Genetic Algorithmn Implementation | |
see: | |
http://www.obitko.com/tutorials/genetic-algorithms/ga-basic-description.php | |
""" | |
import random | |
class GeneticAlgorithm(object): | |
def __init__(self, genetics): | |
self.genetics = genetics | |
pass |
This file contains 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
"""Scrapes interviews from the blog 'the chrome ball incident' for text analysis.""" | |
import urllib | |
import string | |
from bs4 import BeautifulSoup | |
# url of first page of interviews | |
url = 'http://chromeballincident.blogspot.com/search/label/chrome%20ball%20interview' | |
interviews = 0 |
This file contains 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 urllib | |
from datetime import timedelta | |
from operator import itemgetter | |
import csv | |
from bs4 import BeautifulSoup | |
# function that does stuff | |
def match_stats(last_page=2, out_file='out.csv', info=False): | |
""" gets match statistics from oc.tc/matches pages | |
This file contains 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
(* This function removes an {x,y} point if the point does not | |
have a unique x value from a list {{x1,y1},{x2,y2},...} *) | |
removeDupX[l_] := ( | |
nl = l; | |
length = Length[l]; | |
xs = l[[All, 1]]; | |
For[i = 1, i <= length, i++, | |
If[Count[nl[[All, 1]], xs[[i]]] > 1, | |
nl = Delete[nl, i]; | |
xs = Delete[xs, i]; |
This file contains 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
En[n_, a_, V_] := | |
Assuming[a \[Element] Reals && | |
a > 0, (1/8)*Integrate[D[n, x]^2/n, {x, -Infinity, Infinity}] + | |
Integrate[V*n, {x, -Infinity, Infinity}]] | |
V[x_, k_] := (1/2)*k*x^2 | |
\[Psi][x_, a_] := (1/Sqrt[2*Pi*a])*Exp[-x^2/(2*a)] | |
Enf = En[\[Psi][x, a]^2, a, V[x, k]] | |
Solve[D[Enf, a] == 0, a] |
This file contains 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
(* Numerical Schemes *) | |
(* Regular Euler Method *) | |
euler[y0_, npoints_, a_, b_, f_] := ( | |
h = (b - a)/(npoints - 1); | |
y = Table[0, {npoints}]; | |
t = Table[0, {npoints}]; | |
y[[1]] = y0; | |
t[[1]] = a; | |
Do[ | |
yn = y[[n]]; |
This file contains 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
''' | |
Created on Mar 24, 2013 | |
@author: Ben | |
''' | |
import pATournamentReport as r | |
#Example of how to use the classes. | |
base_url = "https://oc.tc" |
NewerOlder