{{ message }}

Instantly share code, notes, and snippets.

🐢

# Jean-Gabriel Youngjg-you

🐢
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)
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()
Last active Aug 29, 2015
HDF5, C interface: From jagged array to variable lenght
View HDF5VL.cpp
 // Test data std::vector< std::vector > 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.