Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Anirudh Jayaraman anirudhjayaraman

🏠
Working from home
View GitHub Profile
@anirudhjayaraman
anirudhjayaraman / graphUndirected.ipynb
Created Jul 28, 2016
Python Implementation of Undirected Graphs (Adjacency List and Adjacency Matrix)
View graphUndirected.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anirudhjayaraman
anirudhjayaraman / DSelect.py
Created Jul 22, 2016
Deterministic Selection (Median of Medians) Algorithm
View DSelect.py
def merge_tuple(a,b):
""" Function to merge two arrays of tuples """
c = []
while len(a) != 0 and len(b) != 0:
if a[0][0] < b[0][0]:
c.append(a[0])
a.remove(a[0])
else:
c.append(b[0])
b.remove(b[0])
@anirudhjayaraman
anirudhjayaraman / linear_regression.ipynb
Created Jul 19, 2016
Linear Regression in scikit learn
View linear_regression.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anirudhjayaraman
anirudhjayaraman / knn.ipynb
Created Jul 18, 2016
KNN algorithm implemented with scikit learn
View knn.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@anirudhjayaraman
anirudhjayaraman / RSelect.py
Created Jul 18, 2016
Randomized Selection Algorithm
View RSelect.py
from random import randrange
def partition(x, pivot_index = 0):
i = 0
if pivot_index !=0: x[0],x[pivot_index] = x[pivot_index],x[0]
for j in range(len(x)-1):
if x[j+1] < x[0]:
x[j+1],x[i+1] = x[i+1],x[j+1]
i += 1
x[0],x[i] = x[i],x[0]
@anirudhjayaraman
anirudhjayaraman / countComparisons.py
Created Jul 13, 2016
Computing Work Done (Total Comparisons) by Quick Sort
View countComparisons.py
#!/usr/bin/env
# Case I
# First element of the unsorted array is chosen as pivot element for sorting using Quick Sort
def countComparisonsWithFirst(x):
""" Counts number of comparisons while using Quick Sort with first element of unsorted array as pivot """
global count_pivot_first
if len(x) == 1 or len(x) == 0:
@anirudhjayaraman
anirudhjayaraman / QuickSort_List.txt
Created Jul 12, 2016
Integer list to sort using Quick Sort (Exercise)
View QuickSort_List.txt
2148
9058
7742
3153
6324
609
7628
5469
7017
504
@anirudhjayaraman
anirudhjayaraman / quicksort.py
Last active Feb 3, 2021
Python code for the Quick Sort Algorithm
View quicksort.py
def quicksort(x):
if len(x) == 1 or len(x) == 0:
return x
else:
pivot = x[0]
i = 0
for j in range(len(x)-1):
if x[j+1] < pivot:
x[j+1],x[i+1] = x[i+1], x[j+1]
i += 1
@anirudhjayaraman
anirudhjayaraman / FrankelWei_2010_2016.r
Created May 15, 2016
Frankel Wei Regression for 2010-2016
View FrankelWei_2010_2016.r
## if fxregime is absent from installed packages, download it and load it
if(!require('fxregime')){
install.packages("fxregime")
}
## load package
library("fxregime")
# load the necessary data related to exchange rates - 'FXRatesCHF'
# this dataset treats CHF as unit currency
# install / load Quandl
@anirudhjayaraman
anirudhjayaraman / FrankelWei_2005_2010.r
Last active May 15, 2016
Auto-detecting Structural Breaks in China’s FX Regime
View FrankelWei_2005_2010.r
## if fxregime or strucchange package is absent from installed packages, download it and load it
if(!require('fxregime')){
install.packages("fxregime")
}
if(!require('strucchange')){
install.packages("strucchange")
}
## load packages
library("fxregime")