Here is an essay version of my class notes from Class 1 of CS183: Startup. Errors and omissions are my own. Credit for good stuff is Peter’s entirely.
CS183: Startup—Notes Essay—The Challenge of the Future
Purpose and Preamble
| #!/usr/bin/python | |
| #Original from here: http://code.activestate.com/recipes/576594/ | |
| #rips Tweets from twitter account, prints as HTML for inclusion in webpage with Date/Time stamp | |
| import time | |
| from urllib2 import urlopen | |
| from BeautifulSoup import BeautifulSoup | |
| # Replace USERNAME with your twitter username | |
| url = u'http://twitter.com/USERNAME?page=%s' |
| *~ | |
| *.o |
| """ | |
| simple example script for running notebooks and saving the resulting notebook. | |
| Usage: `execute_and_save.py foo.ipynb [bar.ipynb [...]]` | |
| Each cell is submitted to the kernel, and the outputs are overwritten and | |
| stored in new notebooks foo_executed.ipynb, etc. | |
| """ | |
| import os,sys,time |
| [~] | |
| ✈ R --silent | |
| > boo = function(x) x*8 | |
| > boo(33) | |
| [1] 264 | |
| > package.skeleton('boo', name='qux') | |
| Creating directories ... | |
| Creating DESCRIPTION ... | |
| Creating NAMESPACE ... |
Here is an essay version of my class notes from Class 1 of CS183: Startup. Errors and omissions are my own. Credit for good stuff is Peter’s entirely.
CS183: Startup—Notes Essay—The Challenge of the Future
Purpose and Preamble
| ## Corey Chivers, 2012 ## | |
| sim_bayes<-function(p=0.5,N=100,y_lim=20,a_a=2,a_b=10,b_a=8,b_b=3) | |
| { | |
| ## Simulate outcomes in advance | |
| outcomes<-sample(1:0,N,prob=c(p,1-p),replace=TRUE) | |
| success<-cumsum(outcomes) | |
| for(frame in 1:N) | |
| { | |
| png(paste("plots/",1000+frame,".png",sep="")) |
| #install.packages("xtsExtra", repos="http://R-Forge.R-project.org") | |
| require(PerformanceAnalytics) | |
| require(xtsExtra) #if you get error, please install xtsExtra from r-forge as shown in the top line | |
| require(RColorBrewer) | |
| #function add alpha or transparency to colors | |
| addalpha <- function(cols,alpha=180) { | |
| rgbcomp <- col2rgb(cols) | |
| rgbcomp[4] <- alpha |
| # Randomly allocating observations into groups, for, e.g. cross-validation | |
| kk <- 10 # Number of partitions, as in "kk-fold cross-validation." | |
| # Here is a data.frame full of good data: | |
| nn <- 1003 | |
| myData <- data.frame(matrix(rnorm(nn * 3), ncol = 3)) | |
| colnames(myData) <- LETTERS[1:3] | |
| # This does not work: | |
| whichK <- sample(LETTERS[1:kk], nrow(myData), replace = T) |
| from __future__ import division | |
| import os | |
| import sys | |
| import codecs | |
| import textwrap | |
| from StringIO import StringIO | |
| from docutils import nodes | |
| from docutils.parsers.rst import Directive, directives | |
| from sphinx.directives.code import LiteralInclude | |
| from sphinx.util.nodes import set_source_info |
| library(quantmod) | |
| # we're pulling the Google VIX index (VXGOG) but this also works for VXAPL, VXGS etc. | |
| # see http://www.cboe.com/micro/equityvix/introduction.aspx | |
| url <- "http://www.cboe.com/publish/ScheduledTask/mktdata/datahouse/VXGOGDailyPrices.csv" | |
| # use read.zoo to read the data directly into a zoo object | |
| z <- read.zoo(url, header=TRUE, sep=",", skip=1, FUN=as.Date, format="%m/%d/%Y") | |
| # convert to xts |