Skip to content

Instantly share code, notes, and snippets.

🐢

Jean-Gabriel Young jg-you

🐢
Block or report user

Report or block jg-you

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jg-you
jg-you / dirichlet_process.r
Last active Aug 29, 2015
Finite Dirichlet process with N(0,1)
View dirichlet_process.r
diri <- function(alpha) {
# Sample from the Dirichlet distribution with parameter (vector) alpha
k <- length (alpha)
Z <- rep(0,k)
for(i in 1:k) {
Z[i] <- rgamma(n=1,shape=alpha[i], rate =1)
S <- sum(Z)
P <- Z/S
}
return(P)
@jg-you
jg-you / degree_of_neighbors.py
Created Apr 13, 2015
NetworkX: Degree of neighbors, by degree
View degree_of_neighbors.py
import networkx as nx
# Mean function (no statistics module in python2)
mean = lambda l: sum(l)/len(l)
# Declare some graph
G = nx.erdos_renyi_graph(200,0.1)
# Prepare raw results container
result = dict()
@jg-you
jg-you / HDF5VL.cpp
Last active Aug 29, 2015
HDF5, C interface: From jagged array to variable lenght
View HDF5VL.cpp
// Test data
std::vector< std::vector<int> > jagged_array(3);
jagged_array[0] = {0};
jagged_array[1] = {0, 1, 2, 3};
jagged_array[2] = {0, 1, 2};
hvl_t * X = (hvl_t *)malloc(jagged_array.size() * sizeof(hvl_t))
for (unsigned int i = 0; i < jagged_array.size(); ++i) {
X[i].len = jagged_array[i].size();
int * ptr = (int *) malloc (X[i].len * sizeof(int));
You can’t perform that action at this time.