Skip to content

Instantly share code, notes, and snippets.

View vvanirudh's full-sized avatar
💭
I may be slow to respond.

Anirudh Vemula vvanirudh

💭
I may be slow to respond.
View GitHub Profile
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
import math
plt.rcParams["figure.figsize"] = (5,2)
fig, ax = plt.subplots()
pdf = lambda x: 0.7 * norm.pdf(x, 0.5, 0.1) + 0.3 * norm.pdf(x, 1, 0.1)
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
plt.rcParams["figure.figsize"] = (5,2)
fig, ax = plt.subplots()
pdf = lambda x: 0.7 * norm.pdf(x, 0.5, 0.1) + 0.3 * norm.pdf(x, 1, 0.1)
dx = 1e-2
@vvanirudh
vvanirudh / auto_git_file.md
Created February 6, 2021 17:33 — forked from darencard/auto_git_file.md
Automatic file git commit/push upon change

Automatically push an updated file whenever it is changed

Linux

  1. Make sure inotify-tools is installed (https://github.com/rvoicilas/inotify-tools)
  2. Configure git as usual
  3. Clone the git repository of interest from github and, if necessary, add file you want to monitor
  4. Allow username/password to be cached so you aren't asked everytime
git config credential.helper store
@vvanirudh
vvanirudh / test_pr2_pick.py
Created July 3, 2020 00:06
Example of PR2 grasping an object using ss-pybullet
#!/usr/bin/env python
from __future__ import print_function
import numpy as np
import pybullet as p
from pybullet_tools.utils import (connect, disable_real_time,
set_default_camera, wait_for_user,
disconnect, load_pybullet, TABLE_URDF, add_data_path,
create_box, FLOOR_URDF, set_point, load_model,
HideOutput, set_base_values, get_unit_vector, WorldSaver,
@vvanirudh
vvanirudh / natural_grad.py
Created February 15, 2019 15:48
Natural Gradient Demo
import numpy as np
from sklearn.utils import shuffle
import random
import argparse
import matplotlib.pyplot as plt
import time
parser = argparse.ArgumentParser()
parser.add_argument('--ng', action='store_true')
parser.add_argument('--seed', type=int, default=10)
@vvanirudh
vvanirudh / runningstat.py
Created March 30, 2018 19:24
Running mean and standard deviation
# From https://www.johndcook.com/blog/standard_deviation/
# and https://github.com/modestyachts/ARS
class RunningStat(object):
def __init__(self, shape=None):
self._n = 0
self._M = np.zeros(shape, dtype = np.float64)
self._S = np.zeros(shape, dtype = np.float64)
self._M2 = np.zeros(shape, dtype = np.float64)
"""
Copyright (c) 2017, Gavin Weiguang Ding
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
@vvanirudh
vvanirudh / Keeping a fork up to date
Last active February 28, 2018 01:13 — forked from CristinaSolana/gist:1885435
Keeping a fork up to date
### 1. Clone your fork:
git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
### 2. Add remote from original repository in your forked repository:
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@vvanirudh
vvanirudh / sliding_mean.py
Created February 6, 2018 21:47
Computing sliding mean to smooth curves
import numpy as np
def sliding_mean(data_array, window=5):
data_array = np.array(data_array)
new_list = []
for i in range(len(data_array)):
indices = range(max(i - window + 1, 0),
min(i + window + 1, len(data_array)))
avg = 0
for j in indices:
@vvanirudh
vvanirudh / random_fourier_features.py
Created February 6, 2018 19:39
Random fourier features using both sines and cosines embedding for Gaussian kernel
from sklearn.base import BaseEstimator
from sklearn.exceptions import NotFittedError
import numpy as np
class IRFF(BaseEstimator):
'''
Random fourier features using the improved embedding
https://www.cs.cmu.edu/~schneide/DougalRandomFeatures_UAI2015.pdf
'''