View horizon plot of french 48 industry portfolio.r
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
#get very helpful Ken French data | |
#for this project we will look at Industry Portfolios | |
#http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip | |
require(latticeExtra) | |
require(PerformanceAnalytics) | |
require(quantmod) | |
#my.url will be the location of the zip file with the data | |
my.url="http://mba.tuck.dartmouth.edu/pages/faculty/ken.french/ftp/48_Industry_Portfolios_daily.zip" |
View findPrimes.R
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
################################################################## | |
# Brute force method for finding all the prime numbers between | |
# nMin and nMax | |
################################################################## | |
findPrimes <- function(nMin, nMax) { | |
# make sure min number is larger than 1, and break if true | |
if (nMin == 1) | |
stop("\n\n **** Error: Please ensure nMin is larger than 1 (nMin > 1) ****") | |
View ai-class.py
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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
__author__ = "Deepak.G.R." | |
__license__ = 'Public Domain' | |
""" | |
usage: | |
Go to command line and type | |
python ai-class.py "topic-name" |
View upstream_challenge.R
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
#Challenge: | |
#Given the following set of numbers {49,8,48,15,47,4,16,23,43,44,42,45,46}. A function picks a random subset of size 6, and takes the minimum, what is the expected value of this function. | |
#put set of numbers into a container | |
test.set <- c(49,8,48,15,47,4,16,23,43,44,42,45,46) | |
#This function picks a random subset of size 6 and takes the minimum | |
upstream.fxn <- function(test.set) {min(sample(test.set,6));} |
View lsos.R
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
## Credit: Taken from: http://stackoverflow.com/questions/1358003/tricks-to-manage-the-available-memory-in-an-r-session | |
# improved list of objects | |
.ls.objects <- function (pos = 1, pattern, order.by, | |
decreasing=FALSE, head=FALSE, n=5) { | |
napply <- function(names, fn) sapply(names, function(x) | |
fn(get(x, pos = pos))) | |
names <- ls(pos = pos, pattern = pattern) | |
obj.class <- napply(names, function(x) as.character(class(x))[1]) | |
obj.mode <- napply(names, mode) | |
obj.type <- ifelse(is.na(obj.class), obj.mode, obj.class) |