Skip to content

Instantly share code, notes, and snippets.

@ahhda
ahhda / test.asm
Created June 20, 2023 10:32
Sample OpCode
PUSH1 0x80
PUSH1 0x40
MSTORE
CALLVALUE
DUP1
ISZERO
PUSH2 0x0010
JUMPI
PUSH1 0x00
DUP1
@ahhda
ahhda / particle_filter.py
Created February 10, 2017 16:22
A particle fitler implemented for the course cs373
# complete particle filter
# Anuj Bansal
#
# --------------
# USER INSTRUCTIONS
#
# Now you will put everything together.
#
# First make sure that your sense and move functions
@ahhda
ahhda / kalmanfilter_1d.py
Last active February 1, 2017 18:11
Simple python code that implements Kalman Filter in 1D
# A program that will iteratively update and
# predict based on the location measurements
# and inferred motions shown below.
def update(mean1, var1, mean2, var2):
new_mean = float(var2 * mean1 + var1 * mean2) / (var1 + var2)
new_var = 1./(1./var1 + 1./var2)
return [new_mean, new_var]
def predict(mean1, var1, mean2, var2):
@ahhda
ahhda / localization_2d.py
Created January 30, 2017 10:40
Python code for 2d localization
# The function localize takes the following arguments:
#
# colors:
# 2D list, each entry either 'R' (for red cell) or 'G' (for green cell)
#
# measurements:
# list of measurements taken by the robot, each entry either 'R' or 'G'
#
# motions:
# list of actions taken by the robot, each entry of the form [dy,dx],
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 12 19:42:55 2015
@author: user
"""
import os
import sys
import pandas as pd
@ahhda
ahhda / naivebayes.py
Created September 20, 2015 11:23
Naive Bayes Classifier
import csv
import random
import math
from sklearn.naive_bayes import GaussianNB
def loadCsv(filename):
lines = csv.reader(open(filename,'rb'))
dataset = list(lines)
for i in range(len(dataset)):
dataset[i] = [float(x) for x in dataset[i]]