Skip to content

Instantly share code, notes, and snippets.

def find_strictly_greater(ary, no):
left = 0
right = len(ary) - 1
# F F F T T T T T
# We want to find first T
# We don't want to miss T
while left < right :
mid = left + (right-left)/2 # This is bias towards left and we are incrementing left so good
import numpy as np
from scipy.stats import t, zscore
def grubbs(X, test='two-tailed', alpha=0.05):
'''
Performs Grubbs' test for outliers recursively until the null hypothesis is
true.
@arcarchit
arcarchit / minimize_food_cost.lp
Last active April 14, 2018 08:28
Linear Programming using Pulp
\* Minimize food cost *\
Minimize
Total_Cost: 0.008 Beef_percentage + 0.013 chicken_percentag
Subject To
Fat_Constraint: 0.1 Beef_percentage + 0.08 chicken_percentag >= 6
Fiber_Constrint: 0.005 Beef_percentage + 0.001 chicken_percentag <= 2
Protine_Constraint: 0.2 Beef_percentage + 0.1 chicken_percentag >= 8
Salt_constraint: 0.005 Beef_percentage + 0.002 chicken_percentag <= 0.4
Total_Sum: Beef_percentage + chicken_percentag = 100
End
@arcarchit
arcarchit / arima.Rmd
Last active April 3, 2018 16:11
Fitting ARIMA model
---
title: "ARIMA model"
author: "Archit Vora"
date: "April 3, 2018"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
@arcarchit
arcarchit / goldensection.py
Created March 11, 2018 09:15 — forked from crankycoder/goldensection.py
A demonstration of the golden section search algorithm
from math import sqrt
phi = (1 + sqrt(5))/2
resphi = 2 - phi
# a and b are the current bounds; the minimum is between them.
# c is the center pointer pushed slightly left towards a
def goldenSectionSearch(f, a, c, b, absolutePrecision):
if abs(a - b) < absolutePrecision:
return (a + b)/2
# Create a new possible center, in the area between c and b, pushed against c
@arcarchit
arcarchit / QP_CVXOPT.ipynb
Created November 26, 2017 06:05
Quadratic Programming CVXOPT
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@arcarchit
arcarchit / gym_env.ipynb
Last active May 7, 2020 10:20
Open AI gym env object
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
import numpy as np
import scipy.stats as stats
from matplotlib import pyplot as plt
class BetaThompson:
def __init__(self, num_bandits, prior_a, prior_b):
self.num_bandits = num_bandits
self.a = prior_a
self.b = prior_b