Skip to content

Instantly share code, notes, and snippets.

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();
#include <iostream>
class DynamicIntArray {
public:
DynamicIntArray() {
contents = new int[2];
capacity = 2;
current_usage = 0;
}
int capacity, current_usage;
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,
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?")
# 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)")
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
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].
@bshlgrs
bshlgrs / gist:239fd687d512e82f350c
Created October 12, 2014 12:53
cheating assignment
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
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)
}
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