Skip to content

Instantly share code, notes, and snippets.

View iveney's full-sized avatar
🏠
Working from home

Ivan Xiao iveney

🏠
Working from home
View GitHub Profile
import gym
import numpy as np
import pickle
env = gym.make('CartPole-v0')
# There are four variable, use a linear model W*x + b so actually five params
# Given some param, run a full episode and compute reward
def run_episode(W, required_perf=1000, render=False):
observation = env.reset()
% sparse signal recovery using L1
rng(0);
N = 256; R = 3; C = 2;
% some superposition of sinoisoids, feel free to change and experiment
f = @(x) .5*sin(3*x).*cos(.1*x)+sin(1.3*x).*sin(x)-.7*sin(.5*x).*cos(2.3*x).*cos(x);
x = linspace(-10*pi, 10*pi, N);
y = f(x);
% Compare Ordinary Least square (no regularization), L2-reguarlized (Ridge),
% L1-regualarized (Lasso) regression in finding the sparse coefficient
% in a underdetermined linear system
rng(0); % for reproducibility
m = 50; % num samples
n = 200; % num variables, note that n > m
A = rand(m, n);
x = zeros(n, 1);
@iveney
iveney / linear_system.matlab
Last active August 29, 2015 14:01
Solutions to under-constrained linear system
>> rng(0)
>> A=randi(10, 2, 5); b=randi(100, 2, 1);
% A = b =
% 9 7 8 7 8 28
% 10 8 4 2 1 5
>> x1=A\b; x2=pinv(A)*b
% x1 = x2 =
@iveney
iveney / README.md
Created February 1, 2013 01:16 — forked from mbostock/.block

This diagram shows the distribution of age groups in the United States over the last 150 years. Use the arrow keys to observe the changing population. Data from the Minnesota Population Center. Use the arrow keys to change the displayed year. The blue bars are the male population for each five-year age bracket, while the pink bars are the female population; the bars are partially transparent so that you can see how they overlap, unlike the traditional side-by-side display which makes it difficult to compare the relative distribution of the sexes.

99.118.110.126 Tue, 11 Sep 2012 20:05:15 -0500
99.118.110.126 Tue, 11 Sep 2012 20:48:17 -0500
99.118.110.126 Sat, 15 Sep 2012 16:43:11 -0500
192.17.96.48 Fri, 2 Nov 2012 11:35:00 -0500
192.17.107.155 Tue, 6 Nov 2012 15:53:06 -0600
192.17.107.155 Tue, 6 Nov 2012 16:40:30 -0600
99.118.110.126 Wed, 7 Nov 2012 15:25:12 -0600
192.17.101.46 Wed, 7 Nov 2012 16:23:13 -0600
192.17.101.46 Wed, 7 Nov 2012 16:52:31 -0600
192.17.101.46 Wed, 7 Nov 2012 17:25:50 -0600
137.189.205.42 Sat, 2 Jan 2010 01:22:53 +0800
114.42.25.25 Tue, 19 Jan 2010 00:54:53 +0800
114.42.25.25 Tue, 19 Jan 2010 01:06:06 +0800
116.29.249.90 Wed, 17 Feb 2010 00:50:45 +0800
192.17.105.204 Sun, 5 Sep 2010 22:46:18 -0500
216.171.18.233 Sun, 13 Feb 2011 12:01:31 -0600
216.171.18.233 Mon, 14 Feb 2011 09:54:07 -0600
216.171.18.233 Sat, 19 Feb 2011 11:33:32 -0600
216.171.18.233 Sun, 20 Feb 2011 11:20:21 -0600
192.17.107.235 Wed, 20 Jul 2011 10:53:58 -0500
@iveney
iveney / ip_location.php
Created December 6, 2011 21:57
alfred extension for finding your ip location
<?php
$ip = $argv[1];
$tags = get_meta_tags("http://www.geobytes.com/IpLocator.htm?GetLocation&template=php3.txt&IpAddress=$argv[1]");
print "{$tags['city']}, {$tags['region']}, {$tags['country']}";
?>
@iveney
iveney / curve fit.py
Created December 4, 2011 01:59
curve fit
"""
Fit a curve using polynomial order of n,
where n is the number of data points
"""
from scipy import *
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
#xs = array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
iveney@iveney-mbp:~$ # find the IP of dapenti.com
iveney@iveney-mbp:~$ dig dapenti.com
; <<>> DiG 9.7.3-P3 <<>> dapenti.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30857
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION: