This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | |
| % |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Gauss function | |
| Gauss(x,w)=1/sqrt(2*pi)./w.*exp(-x.^2/2./w.^2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Benchmark | |
| # Julia | |
| tic(); for i=1:1e5; pi; end; toc() | |
| # Matlab | |
| tic; for i=1:1e5, pi; end; toc; | |
| x = randn(100,1); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| % 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| %% 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; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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. | |
| % |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Amazon S3 | |
| apt-get install s3cmd | |
| s3cmd --configure | |
| s3cmd get --recursive s3://bucketname ./ | |
| du -sh | |
| du -sh ~/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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; | |
| } |