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
| #Model Parameters | |
| S0 = 100; | |
| K =90; | |
| r = 0.025; | |
| sigma = 0.2; | |
| T = 1; | |
| #Simulation parameters | |
| #B = [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000]; #Intervals | |
| #NB = [1000, 500, 200, 100, 50, 20, 10, 5, 2, 1]; # sample size |
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
| r = .05; % Set up parameters and arrays | |
| sig = .10; | |
| T = 1; | |
| s0 = 50; | |
| K = 45; | |
| N = 16; %time steps along path | |
| n = 1000000; | |
| B=100; % number of bins for stratification | |
| NB = n/B; %sample size per bin | |
| del = T/N; |
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
| reg avgmath classize | |
| reg avgverb classize | |
| reg avgmath classize ses | |
| reg avgverb classize ses | |
| gen maimrule = gradesize/(int((gradesize-1)/40)+1) | |
| twoway (scatter classize gradesize, msize(small)) (line maimrule gradesize, lcolor(orange)) | |
| reg avgmath maimrule gradesize |
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
| Personalities = ['Mr. Clarke Kent', 'Dr. Victor Doom', 'Dr. Stephen Strange', 'Dr. Jonathan Osterman'] | |
| def split_names(superhero): | |
| title = superhero.split()[0] | |
| lastname = superhero.split()[-1] | |
| return '{} {}'.format(title, lastname) | |
| list(map(split_names, Personalities)) |
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
| findata <- read.table("C:/Users/DASA0/Desktop/MS Econ/Stat 524/wichern data/T8-4.dat", sep="\t", header=F) | |
| colnames(findata) <- c("JP Morgan", "City bank", "Wells Fargo", "Royal Dutch", "Exxon") | |
| Xbar <- colMeans(findata) | |
| S <- cov(findata) | |
| weight <- diag(1/sqrt(diag(cov(findata)))) | |
| #standardization | |
| stdfindata <- (as.matrix(findata)-rep(1, dim(findata)[1])%*%t(apply(findata, 2, mean)))%*%weight | |
| stdfindata <- as.data.frame(stdfindata) | |
| colnames(stdfindata) <- c("JP Morgan", "City bank", "Wells Fargo", "Royal Dutch", "Exxon") | |
| R <- cov(stdfindata) |
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
| def balanced( a_str): | |
| if len(a_str) %2 !=0: | |
| return False | |
| open_bracks = ['(', '{', '['] | |
| close_bracks = [')', '}', ']'] | |
| par_dict = {open_bracks[0]:close_bracks[0], open_bracks[1]:close_bracks[1], open_bracks[2]:close_bracks[2]} | |
| if a_str[0] in close_bracks: | |
| return False |
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
| def melon_count(boxes, melons): | |
| boxes.sort() | |
| melons.sort() | |
| b= len(boxes) | |
| m = len(melons) | |
| noofmelons = 0 | |
| i = 0 | |
| j = 0 | |
| while(i != b and j != m): |
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 pandas as pd | |
| purchase_1 = pd.Series({'Name': 'Paul', | |
| 'Book Purchased': 'Monte Carlo Methods', | |
| 'Cost': 94.69}) | |
| purchase_2 = pd.Series({'Name': 'Steve', | |
| 'Book Purchased': 'Stochastic Calculus', | |
| 'Cost': 39.55}) | |
| purchase_3 = pd.Series({'Name': 'Brigo', | |
| 'Book Purchased': 'Interest Rate Models', |
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
| from time import time | |
| def present(collection, num): | |
| '''finds out if number of our interest is present in collection''' | |
| return num in collection | |
| def binsearch(ordered, num): | |
| '''binary search function to show position of number of our interest in the collection''' | |
| low = 0 | |
| high = len(ordered)-1 |
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 numpy as np | |
| import pandas as pd | |
| import scipy.stats as stat | |
| import matplotlib.pyplot as plt | |
| chi_squared_df1 = np.random.chisquare(1, size = 100000) | |
| chi_squared_df2 = np.random.chisquare(2, size = 100000) | |
| chi_squared_df3 = np.random.chisquare(3, size = 100000) |