Skip to content

Instantly share code, notes, and snippets.

View tdhopper's full-sized avatar
©️
𝔀𝓸𝓻𝓴𝓲𝓷𝓰 𝓱𝓪𝓻𝓭

Tim Hopper tdhopper

©️
𝔀𝓸𝓻𝓴𝓲𝓷𝓰 𝓱𝓪𝓻𝓭
View GitHub Profile
g := Module[{str, lis, numScores = 12},
str = InputString[];
lis = ToExpression[StringSplit[str, "+"]];
If[Length[lis] != numScores,
Beep[];
Print[lis];
Speak["Length is " <> ToString[Length[lis]]],
Speak[Total[ToExpression[StringSplit[str, "+"]]]];
Print[Total[ToExpression[StringSplit[str, "+"]]]];
]
\begin{align*}
\text{minimize}\qquad & $1 \\\\
\text{subject to}\qquad & $2 \\\\
&x_{i}\geq 0, \qquad i=1,...,n.
\end{align*}
\begin{align*}
\text{minimize}\qquad & $1 \\\\
\text{subject to}\qquad & $2 \\\\
&x_{i}\geq 0, \qquad i=1,...,n.
\end{align*}
#install.packages("catnet",71)
library(catnet)
## Build network
cnet <- cnNew(nodes = c("S", "L", "F", "T", "C"), cats = list(c("winter", "spring", "summer","fall"),
c("NA","SA"), c("salmon","bass"), c("wide","thin"), c("light","medium","dark")),
parents = list(NULL, NULL, c(1,2),c(3),c(3)), probs =
list(
c(.1,.2,.5,.2),
c(0.6, 0.4),
nom0039665aru:code tdhopper$ sudo pip install matplotlib --upgrade
Downloading/unpacking matplotlib
Downloading matplotlib-1.1.0.tar.gz (9.2Mb): 9.2Mb downloaded
Running setup.py egg_info for package matplotlib
basedirlist is: []
============================================================================
BUILDING MATPLOTLIB
matplotlib: 1.1.0
python: 2.7.1 (r271:86832, Jun 25 2011, 05:09:01) [GCC
4.2.1 (Based on Apple Inc. build 5658) (LLVM build
@tdhopper
tdhopper / Code
Created July 11, 2012 15:27
Python parallelization error
from multiprocessing import Pool
from scipy.stats import uniform
def unwrap_self_f(arg, **kwarg):
return C.f(*arg, **kwarg)
class C:
def __init__(self, x = []):
self.x = x
@tdhopper
tdhopper / gist:3153243
Created July 20, 2012 21:09
Plot of average distance between two random points in the unit hyper cube at various dimensions
ListPlot[Table[
Mean[Table[
Norm[RandomReal[1, dim] - RandomReal[1, dim]], {x, 1000}]], {dim,
2, 20}]]
@tdhopper
tdhopper / gist:3315974
Created August 10, 2012 17:32
Split bid data into files
f = open('ydata-ysm-advertiser-bids-v1_0.txt', 'r')
for x in f.readlines():
with open("split/" + x.split()[0].replace("/","") + ".csv", "a+") as out:
out.write(", ".join(x.split()))
out.write("\n")
f = open('ydata-ysm-advertiser-bids-v1_0.txt', 'r')
for x in f.xreadlines():
with open("split/" + x.split()[0].replace("/","") + ".csv", "a+") as out:
out.write(", ".join(x.split()))
out.write("\n")
ggplot(noah.most.frequent.phrase[noah.most.frequent.phrase$user %in% users[1:10],])+
aes(x=day, y=bid, color=factor(user))+geom_jitter(alpha=0.9)
ggplot(noah[noah$user==users[1],])+
aes(x=day, y=bid, color=phrase)+geom_jitter()
qplot(log(key.phrase.counts), geom="histogram")
ggplot(noah[noah$phrase==most.frequent.phrase,])+aes(x=user, y=bid, color=clicks.zero, shape=position.one)+geom_jitter(alpha=0.7, size=10, width=0.5, height=0)
ggplot(noah[noah$phrase==most.frequent.phrase,])+aes(x=day, y=bid, color=clicks.zero, shape=position.one)+geom_jitter(alpha=0.7, size=2, width=0.5, height=0)
ggplot(noah[noah$phrase==most.frequent.phrase,])+aes(x=bid, y=position)+geom_jitter(alpha=0.7, size=2)