Skip to content

Instantly share code, notes, and snippets.

@suzusuzu
suzusuzu / 3d_gaussian_mean_shift.py
Last active November 11, 2019 19:38
An implementation of Gaussian Mean Shift Procedure(3d)
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
from mpl_toolkits.mplot3d import Axes3D
def kde(data, sigma):
def f(x):
l = x.shape[0]
res = np.zeros(l)
for i in range(l):
@suzusuzu
suzusuzu / purecmaes.py
Last active November 12, 2019 10:14
An implementation of CMA-ES (https://arxiv.org/abs/1604.00772)
import numpy as np
def rosenbrock(x):
end = x.shape[0]
a = 100.0
b = 1.0
return np.sum(a * np.power((x[1:] - np.power(x[:end-1], 2)), 2) + np.power((x[:end-1] - b), 2))
def cmaes(dim, f):
# User defined parameters
@suzusuzu
suzusuzu / horseshoe_distribution.ipynb
Last active November 14, 2019 21:56
Horseshoe distribution sampling
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@suzusuzu
suzusuzu / knn_universal_divergence_estimator.py
Last active November 21, 2019 23:23
An Implementation of Divergence Estimation for Multidimensional Densities Via k-Nearest-Neighbor Distance(https://www.princeton.edu/~kulkarni/Papers/Journals/j068_2009_WangKulVer_TransIT.pdf)
import numpy as np
import matplotlib.pyplot as plt
from sklearn.neighbors import NearestNeighbors
def kl_d_norm(mu1, sigma1, mu2, sigma2):
d = np.log(sigma2/sigma1)
d += (sigma1**2 + (mu1 - mu2)**2) / (2 * sigma2**2)
d -= 1/2
return d
using Cascadia
using Gumbo
using HTTP
using JSON
using DataFrames
using Dates
using Plots
# scraping
r = HTTP.request("GET", "https://paperswithcode.com/sota/image-classification-on-imagenet")
@suzusuzu
suzusuzu / stateless2stateful.ipynb
Created December 12, 2019 16:26
stateless2stateful.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@suzusuzu
suzusuzu / non_null_filter.ts
Created July 9, 2020 15:37
non null filter implementation in typescript
const arr = [...Array(100).keys()];
const arr1 = arr.map(x => x*x % 2 == 0 ? x*x : null).filter((x): x is number => x !== null);
// arr1: number[]
const arr2 = arr.flatMap(x => x*x % 2 == 0 ? [x*x] : [])
// arr2: number[]
@suzusuzu
suzusuzu / nsw.jl
Created December 13, 2020 16:43
Navigable Small World(NSW)
using Random
using LinearAlgebra
using DataStructures
using Base
mutable struct Node
data
friend::Set{Node}
end

Keybase proof

I hereby claim:

  • I am suzusuzu on github.
  • I am suzusuzu (https://keybase.io/suzusuzu) on keybase.
  • I have a public key ASBFQYSStcXvfZPPinQlrdVnRQ3qJCbsIUwtJYQOHPdDywo

To claim this, I am signing this object: