Skip to content

Instantly share code, notes, and snippets.

// JavaScript Document
function binary_sequence(N) {
var x = new Array(N);
for (var i=0;i<N-1;i++) {
x[i] = (Math.random() < 0.2);
}
return x;
}
@shimazaki
shimazaki / gist:3485337
Created August 27, 2012 03:48
resampling from 2d data
data %2d data
subplot(2,2,1);
[optW,C,W,Z,X,Y,dx,dy]=sskernel2d(data);
axis square;
fx = sum(Z'* dy);
fy = sum(Z * dx);
@shimazaki
shimazaki / gist:3022258
Last active October 6, 2015 16:38
unix commands
Amazon S3
apt-get install s3cmd
s3cmd --configure
s3cmd get --recursive s3://bucketname ./
du -sh
du -sh ~/*
function [y, t, optw, yconf, C, W] = sskernel(x,t,W)
% [optW, C, W] = sskernel(x,W,t)
%
% Function `sskernel' returns an optimal bandwidth (standard deviation)
% of the Gauss density function used in kernel density estimation.
% Optimization principle is to minimize expected L2 loss function between
% the kernel estimate and an unknown underlying density function.
% An assumption made is merely that samples are drawn from the density
% independently each other.
%
@shimazaki
shimazaki / kde_comparison.m
Created May 23, 2012 09:23
COMPARISON OF KDE METHODS
%% COMPARISON OF KERNEL DENSITY ESTIMATION ALGORITHMS
% FFT METHOD IS >1000 FASTER THAN CONVOLUTION METHOD.
clear all; close all;
ts = 1+rand(1,1e5); %spike time
dt = 0.001;
ts = round(ts/dt)*dt; %make sampling resolution 1/dt;
@shimazaki
shimazaki / mscripts.m
Last active October 4, 2015 23:27
matlab frequently used scripts
% figure setting
figure; set(0,'DefaultAxesFontSize',14);
set(0,'DefaultAxesFontSize',12,'DefaultAxesFontName','Arial');
% adjust axis
axis tight;
tmp = get(gca,'XLim'); set(gca,'XLim',[tmp(1)-.2*diff(tmp),tmp(1)+1.2*diff(tmp)]);
tmp = get(gca,'YLim'); set(gca,'YLim',[tmp(1)-.2*diff(tmp),tmp(1)+1.2*diff(tmp)]);
% save figure
@shimazaki
shimazaki / gist:2506569
Created April 27, 2012 06:30
benchmark test for Julia and Matlab
# Benchmark
# Julia
tic(); for i=1:1e5; pi; end; toc()
# Matlab
tic; for i=1:1e5, pi; end; toc;
x = randn(100,1);
@shimazaki
shimazaki / quick_func.jl
Created April 27, 2012 06:29
quick list of functions for Julia language
# Gauss function
Gauss(x,w)=1/sqrt(2*pi)./w.*exp(-x.^2/2./w.^2)
@shimazaki
shimazaki / sshist.m
Created April 10, 2012 01:35
Function `sshist' returns optimal number of bins in a histogram used for density estimation.
function [optN, optD, edges, C, N] = sshist(x,N)
% [optN, edges, C, N] = sshist(x,N)
%
% Function `sshist' returns the optimal number of bins in a histogram
% used for density estimation.
% Optimization principle is to minimize expected L2 loss function between
% the histogram and an unknown underlying density function.
% An assumption made is merely that samples are drawn from the density
% independently each other.
%