This file contains 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
class LinearRegression: | |
""" | |
Simple linear regression using the Ordinary Least Square method: | |
Coefs = (x.T * X)^-1 * x.T * y | |
where Coefs[0] = q, Coefs[1] = m | |
""" | |
def __init__(self, x, y): # Just give X and Y |
This file contains 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
import networkx as nx | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
class Connectome: | |
def __init__(self, G, quantities = None, time = None): | |
self.G = G |
This file contains 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
import numpy as np | |
import matplotlib.pyplot as plt | |
class Grid3D: | |
def __init__(self, pointsPosition, boxSubdivision):#, cellSize): | |
self._minCorner, self._maxCorner = self._GetCorners(pointsPosition) | |
self.cellSize = [0,0,0]#cellSize | |
self.boxSubdivision = boxSubdivision |
This file contains 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
import numpy as np | |
import trimesh | |
def array_mask_mesh(A : np.ndarray, radius=1., width=0.05, edges = False, path : str='test.obj', volume='cube'): | |
""" | |
Create a 3D object of a (N,M,L) array mask | |
""" | |
centers = np.argwhere(A) | |
radius = [radius]*centers.shape[0] | |
This file contains 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
import networkx as nx | |
import matplotlib.pyplot as plt | |
import numpy as np | |
import matplotlib.cm as colormap | |
heat_equation = True | |
random_walk_diffusion = False | |
np.random.seed(1) |
This file contains 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
// READ THE COMMENT FOR ADDITIONAL INFORMATION | |
#include <iostream> | |
#include <vector> | |
#include <fstream> | |
#include <sstream> | |
#include <algorithm> // for "erase-remove idiom", unique, remove | |
#include <set> | |
#include <random> // for unifrom distribution using mt19937 | |
#include <ctime> // for random seed |
This file contains 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
def flatten_list(lst : list) -> list: | |
""" | |
Description | |
----------- | |
Flatten an irregular list of lists (meaning that it can contain also non lists). If there are multiple nested lists | |
the function must be used as many times as the nested order. | |
""" | |
result = [] |
This file contains 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
from tqdm import tqdm | |
from pandas.util.testing import assert_frame_equal | |
import pandas as pd | |
import numpy as np | |
def df_equal(df1, df2): | |
""" | |
Description | |
----------- |
This file contains 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
import numpy as np | |
def fast_combinations(row : list, self_loops = False) -> np.array: | |
""" | |
Description | |
----------- | |
Fast way to obtain the combination of all the elements inside a list using Numpy. | |
Self connections are present. | |
Parameters |
This file contains 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
import pandas as pd | |
import numpy as np | |
from tqdm import tqdm | |
def fast_combinations(row : list, self_loops = False) -> np.array: | |
""" | |
Description | |
----------- | |
Fast way to obtain the combination of all the elements inside a list using Numpy. | |
Self connections are present. |
NewerOlder