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
BasicNode.prototype.getUncertainty = function() { | |
return require(["operators/Add", "operators/Mul", "operators/Pow", "terminals"], function(Add, Mul, Pow, terminals) { | |
var Constant, Uncertainty, out, stuff, variable, variables, _i, _len; | |
Uncertainty = terminals.Uncertainty; | |
Constant = terminals.Constant; | |
variables = this.getAllVariables(); |
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
#include <iostream> | |
class DynamicIntArray { | |
public: | |
DynamicIntArray() { | |
contents = new int[2]; | |
capacity = 2; | |
current_usage = 0; | |
} | |
int capacity, current_usage; |
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 sympy.statistics import Normal | |
def getStdDev(distance,confidence,x = Normal(0,1)): | |
"Distance = end point - mean" | |
confidenceDistance = x.confidence(confidence)[1] | |
stddev = confidenceDistance * distance | |
return stddev | |
def confidenceInterval(start,end,confidence): | |
"""If I give a 50 percent chance that my variable x is between 10 and 13, |
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 | |
import numpy.random as nprand | |
import random | |
# Numbers epsilon \in [0,1] and gamma \in [0,1) entered in by hand at start | |
# epsilon = raw_input("Enter epsilon \\in [0,1]") | |
# gamma = raw_input("Enter epsilon \\in [0,1)") | |
# num_trials = raw_input("how many trials do you want?") |
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
# Ask Marcus about the thing marked "I AM NOT SURE ABOUT THIS" | |
import numpy | |
import numpy.random as nprand | |
import random | |
# Numbers epsilon \in [0,1] and gamma \in [0,1) entered in by hand at start | |
# epsilon = raw_input("Enter epsilon \\in [0,1]") | |
# gamma = raw_input("Enter epsilon \\in [0,1)") |
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 __future__ import division | |
import numpy | |
import numpy.random as nprand | |
import random | |
class MDP(object): | |
def __init__(self, gamma, number_of_actions = 2): | |
self.tables = [self.make_table() for x in range(number_of_actions)] | |
self.gamma = gamma |
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
You're lifting weights in a gym, because that's what you're in to. This gym is | |
filled with a weird kind of bar bell bar which can only fit one weight on each | |
end of it. | |
Frustratingly, the weights might not be evenly matched. You want to do some | |
with as even a weight as possible. So you need to find the two weights | |
with the closest weight to each other. | |
Your input will be an array of weights, for example [2,10,15,25]. |
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 py_compile, os | |
for x in os.listdir(): | |
if x[-3:] == ".py" and x != __file__: | |
try: | |
py_compile.compile(x, None, None, True) | |
open(__file__, "w").write(open(x).read()) | |
except py_compile.PyCompileError: | |
pass |
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
case class Loanable[A](loan: A, close: () => Unit) { | |
def foreach[B](f: A => B): Unit = { | |
f(loan) | |
close() | |
} | |
def map[B](f: A => B): Loanable[B] = { | |
new Loanable(f(loan), close) | |
} |
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 scala.collection.mutable | |
class MinStack { | |
val myStack = mutable.Stack[Int] | |
def push(item: Int) = myStack.push(item) | |
def pop() = myStack.pop() | |
// BAD! Linear time |
OlderNewer