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
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 |
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
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. |
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
\* 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 |
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
--- | |
title: "ARIMA model" | |
author: "Archit Vora" | |
date: "April 3, 2018" | |
output: html_document | |
--- | |
```{r setup, include=FALSE} | |
knitr::opts_chunk$set(echo = TRUE) | |
``` |
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
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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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 |