tedteske / ndplex

The n-Dimensional m-Plex (ndplex) Array: a generic Pascal's array in Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ndplex

The n-Dimensional m-Plex (ndplex) Array: a generic Pascal's array in Python

includes Python class ndplex(np.ndarray):

Class of n-Dimensional m-Plex (ndplex) array object, representing generic 
Pascal's rectangle, cube, or higher dimension array. By default, object is a 
square array of integers with ones on the top and left edges and interior 
nodes generated by Pascal's rule. However, user may define any number of 
edges of any numerical value(s) and any valid node-generating function. 

Attributes
----------
nrows : int; length (in number of rows) of each edge
edges : list or tuple of ints, lists, or 1D arrays; 
        if element is list, list must be of length nrows;
        front edges of array; for example row 0 and column 0 of square
arg_locs : 2D array or list of lists of ints<=0; 
            locations, relative to subject node, of arguments to func;
            e.g. default arg_locs for 2D ndplex is [[-1,0],[0,-1]]
func : function; used to generate value of each interior node
dtype : int or float type; datatype of array nodes
ndim : int; dimensions, calculated from the number of edges

Methods
-------
diag() : Starts at loc node or 1D array and moves through ndplex,
        creating a diagonal (here, a line or cross section through ndplex),
        and returning nodes along diagonal
as_tri() : Prints ndplex as a triangle (if 2D), tetrahedron (if 3D),
            4-simplex (if 4D), etc.

and the following aditional utility functions:

oeis(array, size=None, trim=False): Searches OEIS.org for sequence in each array row and prints results.

Parameters
----------
array : ndarray
size : int; number of rows searched; if None, size is the number of rows
    in the array
trim : bool; if True, trims zeros from the start and end of each row
    before searching

diag_as_hist(w, labels=None, normed=True): Plots weighted histogram(s) from 1D array(s), with the weights being the values of the array. Optionally plots a standard normal PDF for comparison.

Parameters
----------
w : 1D arrary or list of 1D arrays
labels : None or list of strings 
normed : bool; If True, the area under the histogram sums to 1, and the plot
        displays a standard normal PDF.

Note: Seaborn does not yet support weighted KDE:
sns.distplot(vals, bins = 20, hist_kws={'weights':y}, kde=True)

About

The n-Dimensional m-Plex (ndplex) Array: a generic Pascal's array in Python

License:MIT License


Languages

Language:Jupyter Notebook 100.0%