@totemorg/man
v2.28.0
Published
matrix manipulator
Downloads
16
Readme
MAN
Extends MathJX with various AI/ML methods:
- light weight image processing
- symbolic algebra
- time series analysis ( digital signal processing, spectral, kalman filter, autoregressive moving average )
- liner programming ( simplex, blossom, hidden markov methods, optimal global alignment )
- matrix decompositions ( eigen spectrums, singular value decomposition )
- bayesian belief networks
- regression methods ( logistic, support vector, other )
- non-linear optimizers ( least cost path, linear programming, gradient descent, newton-raphton )
- neural networks ( convolutional, caffe CNN, recurrent, tensor flow language models )
- cluster analysis ( K-means, expectation maximization, density based scan, support vector machine, principle component analysis, tsne )
- special functions ( gamma, multivariate normal, rieman zeta, crypto ).
See the Program Reference for method details.
Install
npm install @totemorg/man # install
npm update
Manage
npm run start # Unit test
npm run verminor # Roll minor version
npm run vermajor # Roll major version
npm run redoc # Regen documentation
Usage
Acquire and optionally configure MAN as follows:
import { $ } from "@totemorg/man");
$.config({
key: value, // set key
"key.key": value, // indexed set
"key.key.": value // indexed append
});
where configuration keys follow ENUMS deep copy conventions. See the Program Reference for usage examples.
Program Reference
MAN
Process mathjx script using required AI/ML extensions listed below. This module documented in accordance with jsdoc.
Requires: module:enums, module:mathjx, module:kalman-filter, module:arima, module:crypto, module:mathjs, module:fft-js, module:nodehmm, module:node-svd, module:node-svm, module:mljs, module:jimp, module:jsbayes, module:recurrent-js, module:gamma, module:expectation-maximization, module:multivariate-normal, module:newton-raphson, module:random-seed, module:edmonds-blossom, module:simple-simplex, module:@tensorflow/tfjs, module:sdbscan, module:tsne-js
Author: ACMESDS
| Param | Type | Description | | --- | --- | --- | | pgm | String | MathJx script to process. | | ctx | Object | Context to run script. |
Example ( <caption>Eval a js or mathjs script in a context ctx)
var
ctx = $( "script", ctx, ctx => { // eval with callback
Trace("updated context", ctx);
} ),
ctx = "script".$( ctx ), // abbreviated
{ x, y, ... } = "script".$( ctx ) || {}; // with context x,y extractions
Example (Create a matrix)
var
A = $( N, (n,A) => A[n] = ... ) , // define N-length vector
A = $( [M,N], (n,m,A) => A[m][n] = ... ) ; // define M x N matrrix
Example (Index a matrix)
A.$( (n,A) => A[n] = ... ) // index vector with callback
A.$$( (n,m,A) => A[n][m] = ... ) // index matrix with callback
Example (Sample a matrix with optional callback cb(val))
var
B = A.get( idx , cb),
B = A.get( "key, ...", cb ),
B = A.get( [idx, ...] , cb),
B = A.get( [key, ...] , cb ),
B = A.get( {rekey: { toKey: "fromKey", ... }, cb ),
B = A.get( {draw: N}, cb ),
B = A.get( {start:N, count:N}, cb ),
B = A.get( {KEY_starts: "with", ...}, cb ),
B = A.get( {KEY_ends: "with", ...}, cb )
Example (Import functions to $.somefn and to $( "somefn(...)" ))
$( {
somefn: function (args) { ... },
:
:
} );
Example (Use the task sharder)
$( {
keys: "i,j,k", // array indicies
i: [0,1,2,3], // domain of index i
j: [4,8], // domain of index j
k: [0], // domain of index k
qos: 0, // regulation time in ms if not zero
local: false, // enable to run task local, i.e. w/o workers and nodes
workers: 4, // limit number of workers (aka cores) per node
nodes: 3 // limit number of nodes (ala locales) in the cluster
},
// here, a simple task that returns a message
$ => "my result is " + (i + j*k) + " from " + $.worker + " on " + $.node,
// here, a simple callback that displays the task results
msg => console.log(msg)
);
Example (Aggregate and save events ev = {at: "KEY", ...} to ctx.Save_KEY)
[ev, ...].save( ctx, evs => { // unsave events ... } );
"query".save( ctx, evs => { //unsave events ... } );
Example (Indexing methods)
$( "mathjs script", ctx, ctx => { ... } )
$( "mathjs script", ctx )
$( "mathjs script" )
$( [M,N], (m,n,A) => { A[m][n] = ... } )
$( N, (n,A) => { A[n] = ... } )
$({ // import functions
f: (...) => { ... },
...
})
$({ // task sharding
keys: "i,j,...", // array indicies
i: [...], // domain of index i
j: [...], // domain of index j
k: [...], // domain of index k
qos: N, // regulation time in ms if not zero
local: false, // enable to run task local, i.e. w/o workers and nodes
workers: N, // limit number of workers (aka cores) per node
nodes: N // limit number of nodes (ala locales) in the cluster
},
// here, a simple task that returns a message
$ => "my result is " + (i + j*k) + " from " + $.worker + " on " + $.node,
// here, a simple callback that displays the task results
msg => console.log(msg)
);
Example (Eval a mathjs script with optional callback and optional context)
var
ctx = $( "mathjs script", ctx, ctx => {
x: 1,
y: 20, ...
} );
Example (Eval with extraction of context keys)
const {x, y, ... } = $( "mathjs script", ctx ) || {};
Example (Import functions)
$( {
somefn: function (args) { ... },
:
:
} );
Example (Use the task sharder)
$( {
keys: "i,j,k", // array indicies
i: [0,1,2,3], // domain of index i
j: [4,8], // domain of index j
k: [0], // domain of index k
qos: 0, // regulation time in ms if not zero
local: false, // enable to run task local, i.e. w/o workers and nodes
workers: 4, // limit number of workers (aka cores) per node
nodes: 3 // limit number of nodes (ala locales) in the cluster
},
// here, a simple task that returns a message
$ => "my result is " + (i + j*k) + " from " + $.worker + " on " + $.node,
// here, a simple callback that displays the task results
msg => console.log(msg)
);
String
String~$()
Kind: inner method of String
Array
Array~copy()
Kind: inner method of Array
Array~dist()
Kind: inner method of Array
Array~nearestOf()
Kind: inner method of Array
Array~batch()
Kind: inner method of Array
Array~flush()
Kind: inner method of Array
Array~draw()
Kind: inner method of Array
Array~match()
Kind: inner method of Array
Array~replace()
Kind: inner method of Array
Array~unique()
Kind: inner method of Array
JIMP
- JIMP
- ~scripts
- ~saveKeys
- ~$
- ~help
- ~save()
- ~sym()
- ~resnet()
- ~rp()
- ~eye()
- ~oga([Array], [Array], [Function])
- ~getEv(d, keys)
- ~putEv()
- ~stateSize()
- ~BIC()
- ~draw()
- ~cum()
- ~crf()
- ~propEv()
- ~CMI()
- ~mcmc()
- ~indicate()
- ~boost(cycle, sql, solve, trace, hypo)
- ~proj()
- ~orthoNorm()
- ~MaxFlowMinCut()
- ~ranreg()
- ~degrees()
- ~degree()
- ~nodes()
- ~spectrum()
- ~any()
- ~all()
- ~isoperi()
- ~edges()
- ~clone()
- ~graph()
- ~union()
- ~empty()
- ~ranregs()
- ~rand()
- ~randRot()
- ~ols(use, x, y, solve, cb)
- ~train()
- ~predict(cls, use, x, y, solve, cb)
- ~qda_train()
- ~qda_predict()
- ~beta_train()
- ~beta_predict()
- ~rnn_train()
- ~rnn_predict()
- ~ann_train()
- ~ann_predict()
- ~dnn_train()
- ~dnn_predict()
- ~dhs_train()
- ~dhs_predict()
- ~lda_train()
- ~lda_predict()
- ~ror_train()
- ~ror_predict()
- ~dtr_train()
- ~dtr_predict()
- ~raf_train()
- ~raf_predict()
- ~nab_train()
- ~nab_predict()
- ~som_train()
- ~som_predict()
- ~ols_train()
- ~ols_predict()
- ~svm_train()
- ~svm_predict()
- ~lrm_train()
- ~lrm_predict()
- ~knn_train()
- ~knn_predict()
- ~pls_train()
- ~pls_predict()
- ~triggerProfile()
- ~coherenceIntervals()
- ~arrivalRates()
- ~estGauss()
- ~svd()
- ~evd()
- ~rng()
- ~xcorr()
- ~dht()
- ~dft()
- ~pwrem()
- ~pwrec()
- ~wkpsd()
- ~psd()
- ~evpsd()
- ~udev()
- ~expdev()
- ~cumsum()
- ~conf()
- ~tolAtConf()
- ~tolsAtConf()
- ~loggamma()
- ~beta()
- ~cumbeta()
- ~sinc()
- ~rect()
- ~tri()
- ~negexp()
- ~lorenzian()
- ~zeta()
- ~infer()
- ~mle()
- ~mvn()
- ~lfa()
- ~lma()
- ~rnn()
- ~XX()
JIMP~scripts
Kind: inner property of JIMP
scripts.conf
Kind: static property of scripts
scripts.pca
Kind: static property of scripts
scripts.roc
Kind: static property of scripts
scripts.snr
Kind: static property of scripts
scripts.p0
Kind: static property of scripts
scripts.pw
Kind: static property of scripts
scripts.wk
Kind: static property of scripts
scripts.trigger()
Kind: static method of scripts
JIMP~saveKeys
Kind: inner property of JIMP
JIMP~$
Kind: inner property of JIMP
JIMP~help
Kind: inner property of JIMP
JIMP~save()
Kind: inner method of JIMP
JIMP~sym()
Kind: inner method of JIMP
JIMP~resnet()
Kind: inner method of JIMP
JIMP~rp()
Kind: inner method of JIMP
JIMP~eye()
Kind: inner method of JIMP
JIMP~oga([Array], [Array], [Function])
Neddleman-Wunch optimal global alignment.
Kind: inner method of JIMP
| Param | Description | | --- | --- | | [Array] | x word list | | [Array] | y word list | | [Function] | s Distance function(gap marker, word) |
JIMP~getEv(d, keys)
Get Event from event network.
Kind: inner method of JIMP
| Param | Type | Description | | --- | --- | --- | | d | Array | data | | keys | Array | keys into data |
JIMP~putEv()
Kind: inner method of JIMP
JIMP~stateSize()
Kind: inner method of JIMP
JIMP~BIC()
Return BIC score for specified Bayesian belief network.
Kind: inner method of JIMP
JIMP~draw()
Draw deviate from a specified distribution.
Kind: inner method of JIMP
JIMP~cum()
Cummulative sum.
Kind: inner method of JIMP
JIMP~crf()
Draw Bayesian network deviates with specifed Conditional Random Field
Kind: inner method of JIMP
JIMP~propEv()
Propagate evidents in a Bayesian belief network.
Kind: inner method of JIMP
JIMP~CMI()
Conditional mutual information for Baysian belief network.
Kind: inner method of JIMP
JIMP~mcmc()
Markov Chain Monte Carlo process.
Kind: inner method of JIMP
JIMP~indicate()
Returns indicator of a test vector.
Kind: inner method of JIMP
JIMP~boost(cycle, sql, solve, trace, hypo)
Dempster method to boost hypothesis from cycle t>=1; t=1 will initialize the boosting process. Provide an sql connector to ingest data; a solve hash containing boosting parameters ( alpha, eps, etc used by adaBoost); and a trace flag to enable tracing;
The hypothesis callback hypo(x,keys) will
return tested hypo if keys specified
return learned hypo keys if x specified
save hypo keys to boost stash if neither specified
Kind: inner method of JIMP
| Param | Type | Description | | --- | --- | --- | | cycle | Number | number being boosted >=1 | | sql | Object | connector | | solve | Object | boosting options and stashes: alpha, eps, h, samples, mixes, thresh | | trace | function | callback(msg) to handel messages | | hypo | Funtion | callback(x,keys) |
JIMP~proj()
Return vector projection.
Kind: inner method of JIMP
JIMP~orthoNorm()
Kind: inner method of JIMP
JIMP~MaxFlowMinCut()
Contruct max-flow-min-cuts for specified graph.
Kind: inner method of JIMP
JIMP~ranreg()
Return an adjaceny matrix for a random n-node, d-regular graph.
Kind: inner method of JIMP
JIMP~degrees()
Return node degress for graph with adjaceny matrix A.
Kind: inner method of JIMP
JIMP~degree()
Return graph degree given its adjacency matgrix A.
Kind: inner method of JIMP
JIMP~nodes()
Return node of a graph with adjacency matrix A.
Kind: inner method of JIMP
JIMP~spectrum()
Return eigen spectrum of a graph with adjacency magtrix A.
Kind: inner method of JIMP
JIMP~any()
Return true is any items true.
Kind: inner method of JIMP
JIMP~all()
Returns true is all items true.
Kind: inner method of JIMP
JIMP~isoperi()
Return Cheeger's isoperimetric constant for a graph with adjacency matrix A and vertex set V. Uses random set partitions when a nonzero block size is specified; otherwise, exhaustively enumerates all partitions.
Kind: inner method of JIMP
JIMP~edges()
Return edges E of a graph whose adjacency matrix is A.
Kind: inner method of JIMP
JIMP~clone()
Clone a graph given its adjacency matrix A.
Kind: inner method of JIMP
JIMP~graph()
Return graph G (nodes V, edges E, adjacency matrix A) given its adjacency matrix A.
Kind: inner method of JIMP
JIMP~union()
Return graph composition of two graphs with adjacency matricies A and B.
Kind: inner method of JIMP
JIMP~empty()
Return an unconnected empty graph having N nodes.
Kind: inner method of JIMP
JIMP~ranregs()
Callback cb with random n-node, d[i]-regular graphs given the desired number of random permutations m[i].
Kind: inner method of JIMP
JIMP~rand()
MxN random matrix
Kind: inner method of JIMP
JIMP~randRot()
KxK random rotation matrix
Kind: inner method of JIMP
JIMP~ols(use, x, y, solve, cb)
Train a cls classifier using the specified regression use-method given the feature vectors x and optional (when supervised) labels y, and regression solve options.
The y labels (<0 indicates unlabelled) are used by supervised regressors
(like OLS, logit, etc) to estimate their fitting parameters, as well as by
unsupervised regressors (like qda, som, etc) to remap their unordered solutions
into a consistant order (by computing a confusion matrix against the supplied and
the predicted labels).
Kind: inner method of JIMP
| Param | Type | Description | | --- | --- | --- | | use | String | regression method | | x | Array | sampled feature vectors | | y | Array | labels of samples vectors (or null) | | solve | Object | regression options | | cb | function | callback(cls) |
JIMP~train()
Kind: inner method of JIMP
JIMP~predict(cls, use, x, y, solve, cb)
Return predicted labels y given a list x of feature vectors.
Kind: inner method of JIMP
| Param | Type | Description | | --- | --- | --- | | cls | Object | classifier hash | | use | String | regression method | | x | Array | sampled feature vectors | | y | Array | labels of samples vectors (or null) | | solve | Object | regression options | | cb | function | callback(ctx) |
JIMP~qda_train()
Kind: inner method of JIMP
JIMP~qda_predict()
Kind: inner method of JIMP
JIMP~beta_train()
Kind: inner method of JIMP
JIMP~beta_predict()
Kind: inner method of JIMP
JIMP~rnn_train()
Kind: inner method of JIMP
JIMP~rnn_predict()
Kind: inner method of JIMP
JIMP~ann_train()
Kind: inner method of JIMP
JIMP~ann_predict()
Kind: inner method of JIMP
JIMP~dnn_train()
Kind: inner method of JIMP
JIMP~dnn_predict()
Kind: inner method of JIMP
JIMP~dhs_train()
Kind: inner method of JIMP
JIMP~dhs_predict()
Kind: inner method of JIMP
JIMP~lda_train()
Kind: inner method of JIMP
JIMP~lda_predict()
Kind: inner method of JIMP
JIMP~ror_train()
Kind: inner method of JIMP
JIMP~ror_predict()
Kind: inner method of JIMP
JIMP~dtr_train()
Kind: inner method of JIMP
JIMP~dtr_predict()
Kind: inner method of JIMP
JIMP~raf_train()
Kind: inner method of JIMP
JIMP~raf_predict()
Kind: inner method of JIMP
JIMP~nab_train()
Kind: inner method of JIMP
JIMP~nab_predict()
Kind: inner method of JIMP
JIMP~som_train()
Kind: inner method of JIMP
JIMP~som_predict()
Kind: inner method of JIMP
JIMP~ols_train()
Kind: inner method of JIMP
JIMP~ols_predict()
Kind: inner method of JIMP
JIMP~svm_train()
Kind: inner method of JIMP
JIMP~svm_predict()
Kind: inner method of JIMP
JIMP~lrm_train()
Kind: inner method of JIMP
JIMP~lrm_predict()
Kind: inner method of JIMP
JIMP~knn_train()
Kind: inner method of JIMP
JIMP~knn_predict()
Kind: inner method of JIMP
JIMP~pls_train()
Kind: inner method of JIMP
JIMP~pls_predict()
Kind: inner method of JIMP
JIMP~triggerProfile()
Use the Paley-Wiener Theorem to return the trigger function stats:
x = normalized time interval of recovered trigger
h = recovered trigger function at normalized times x
modH = Fourier modulous of recovered trigger at frequencies f
argH = Fourier argument of recovered trigger at frequencies f
f = spectral frequencies
via the callback cb(stats) given a solve request:
evs = events list
refLambda = ref mean arrival rate (for debugging)
alpha = assumed detector gain
N = profile sample times = max coherence intervals
model = correlation model name
Tc = coherence time of arrival process
T = observation time
Kind: inner method of JIMP
JIMP~coherenceIntervals()
Callback with coherence intervals M, SNR, etc given solve: f[k] = observed probability mass at count levels k = 0 ... Kmax-1 T = observation time N = number of events collected use = "lma" | "lfa" | "bfs" lma = [initial M] lfa = [initial M] bfs = [start, end, increment M]
Kind: inner method of JIMP
JIMP~arrivalRates()
Kind: inner method of JIMP
JIMP~estGauss()
Kind: inner method of JIMP
JIMP~svd()
Returns singular value decomposition of a real matrix A.
Kind: inner method of JIMP
JIMP~evd()
Returns eigen value decomposition of a real matrix A.
Kind: inner method of JIMP
JIMP~rng()
Returns range from min to max in N steps.
Kind: inner method of JIMP
JIMP~xcorr()
Returns N x N complex correlation matrix Xccf [unitless] sampled from the given 2N+1, odd length, complex correlation function xccf [unitless]. Because Xccf is band symmetric, its k'th diag at lag k contains xccf(lag k) = xccf[ N+1 + k ] , k = -N:N
Kind: inner method of JIMP
JIMP~dht()
Returns discrete Hilbert transform of an odd length array f
Kind: inner method of JIMP
JIMP~dft()
Returns unnormalized dft/idft of an odd length, real or complex array F.
Kind: inner method of JIMP
JIMP~pwrem()
Returns paley-weiner remainder given zeros z in complex UHP at frequencies nu = [ -f0, ... +f0 ] [Hz]
Kind: inner method of JIMP
JIMP~pwrec()
Returns paley-weiner reconstructed trigger H(nu) = |H(nu)| exp( j*argH(nu) ) given its modulous and its zeros z=[z1,...] in complex UHP.
Kind: inner method of JIMP
JIMP~wkpsd()
Returns weiner-kinchine psd [Hz] at frequencies nu [Hz] = [-f0 ... +f0] of a complex corr func ccf [Hz^2] of len N = 2^K + 1 defined overan interval T [1/Hz], where the cutoff f0 is 1/2 the implied sampling rate N/T.
Kind: inner method of JIMP
JIMP~psd()
Returns power spectral density [Hz] of events at times [t1,t2,...] over interval T [1/Hz] at the specified frequencies nu [Hz].
Kind: inner method of JIMP
JIMP~evpsd()
Return psd [Hz] at the specified frequencies nu [Hz], and the mean event rate [Hz] given events evs = [{tKey: t1,idKey: id}, {tKey: t2, idKey: id}, ... ] over an observation interval T [1/Hz] with event idKey and tKey as provided.
Kind: inner method of JIMP
JIMP~udev()
Returns uniform random deviate on [0...a]
Kind: inner method of JIMP
JIMP~expdev()
Returns exp random deviate with prescribed mean a
Kind: inner method of JIMP
JIMP~cumsum()
Returns cummulative sum of x.
Kind: inner method of JIMP
JIMP~conf()
Kind: inner method of JIMP
JIMP~tolAtConf()
Kind: inner method of JIMP
JIMP~tolsAtConf()
Kind: inner method of JIMP
JIMP~loggamma()
Kind: inner method of JIMP
JIMP~beta()
Kind: inner method of JIMP
JIMP~cumbeta()
Kind: inner method of JIMP
JIMP~sinc()
Kind: inner method of JIMP
JIMP~rect()
Kind: inner method of JIMP
JIMP~tri()
Kind: inner method of JIMP
JIMP~negexp()
Kind: inner method of JIMP
JIMP~lorenzian()
Kind: inner method of JIMP
JIMP~zeta()
Kind: inner method of JIMP
JIMP~infer()
Kind: inner method of JIMP
JIMP~mle()
Kind: inner method of JIMP
JIMP~mvn()
Kind: inner method of JIMP
JIMP~lfa()
Kind: inner method of JIMP
JIMP~lma()
Kind: inner method of JIMP
JIMP~rnn()
Kind: inner method of JIMP
JIMP~XX()
Kind: inner method of JIMP
Contacting, Contributing, Following
Feel free to
- submit and status TOTEM issues
- contribute to TOTEM notebooks
- revise TOTEM requirements
- browse TOTEM holdings
- or follow TOTEM milestones
License
© 2012 ACMESDS