Skip to content

Instantly share code, notes, and snippets.

View wanirepo's full-sized avatar

Choong-Wan Woo wanirepo

View GitHub Profile
@wanirepo
wanirepo / SBM_likelihood.m
Created October 21, 2014 16:31
log-likelihood estimation for simple Stochastic Block Model (SBM) (undirected, unweighted) based on Maximum Likelihood estimation.
function L = SBM_likelihood(A, z, varargin)
% usage: L = SBM_likelihood(A, z)
%
% feature: log-likelihood estimation for simple Stochastic Block Model (SBM)
% (undirected, unweighted) based on Maximum Likelihood estimation.
%
% input: A adjacency matrix (simple graph)
% z group membership
%
@wanirepo
wanirepo / KL_heuristic_k2.m
Last active August 29, 2015 14:07
Uses the Kernighan-Lin (KL) heuristic to optimize any partition score function.
function [bestL, bestP, info] = KL_heuristic_k2(A, varargin)
% usage: [bestL, bestP, info] = KL_heuristic_k2(A, varargin)
%
% feature: use the Kernighan-Lin (KL) heuristic to optimize any partition
% score function, e.g., modularity Q or stochastic block model's
% likelihood function. This works only for 2 partitioning problem.
%
% input: A adjacency matrix
%
@wanirepo
wanirepo / wani_robustPCA_testing.m
Last active August 29, 2015 14:19
Applying robust PCA on an example dataset (to download this dataset, see https://github.com/wanirepo/SAS2015_PatRec)
cd('/Users/clinpsywoo/github/fastRPCA');
setup_fastRPCA;
% load an example data
load('/Users/clinpsywoo/github/SAS2015_PatRec/data.mat');
X = dat.dat;
SS = svd(X, 'econ'); % can decompose x or x', but faster when rows >> cols
% 3 solvers (5 variants)
% 1) constrained
@wanirepo
wanirepo / surface_example.m
Last active July 31, 2016 23:56
surface mapping example
poscm = colormap_tor([0.96 0.41 0], [1 1 0]); % warm
negcm = colormap_tor([0.11 0.46 1], [.23 1 1]); % cools
cluster_surf(cl ,which('surf_BrainMesh_ICBM152Right_smoothed.mat'), 2, 'heatmap', 'colormaps', poscm, negcm)
axis vis3d;
@wanirepo
wanirepo / replication_simulation.m
Last active January 11, 2019 09:03
A code for a simulation in Hong et al., in prep
% In this simulation we examined how reliable peak distance and pattern correlation
% by comparing two simulated data with the same ground truth patterns of signal.
% define SNR levels
snr_all = [.1 .3 .5 .7 .9 1.1];
% create ground truth pattern
pattern = [0.4 1.7 0.5 0.7 0.2