matrix manipulator
npm install @totemorg/manExtends 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 usage details.
npm install @totemorg/man # install
npm update
npm run start # Unit test
npm run verminor # Roll minor version
npm run vermajor # Roll major version
npm run redoc # Regen documentation
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.
Extend mathjs script with mathjx script
and various numerical methods.
This module documented in accordance with jsdoc.
Reduce a mathjx-script to a mathjs-script
using the following language model:
if TEST
BLOCK
elseif TEST
BLOCK
:
else
BLOCK
endswitch TEST
case TEST
BLOCK
:
default TEST
BLOCK
end
try
BLOCK
catch
BLOCK
end
for INDEX
BLOCK
end
while TEST
BLOCK
end
until TEST
BLOCK
end
when EVENT
BLOCK
end
def f=(x,y,...)
BLOCK
end
Inline functions are also supported using fat-arrows:
(x,y,...) => {
BLOCK
}
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)
``js
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) js
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) js
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)) js
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(...)" )) js
$( {
somefn: function (args) { ... },
:
:
} );
``
Example (Use the task sharder) js
$( {
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) js
[ev, ...].save( ctx, evs => { // unsave events ... } );
"query".save( ctx, evs => { //unsave events ... } );
``
Example (Indexing methods) js
$( "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) js
var
ctx = $( "mathjs script", ctx, ctx => {
x: 1,
y: 20, ...
} );
``
Example (Eval with extraction of context keys) js
const {x, y, ... } = $( "mathjs script", ctx ) || {};
``
Example (Import functions) js`
$( {
somefn: function (args) { ... },
:
:
} );`
Example (Use the task sharder) js
$( {
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)
);
`
if TEST
BLOCK
elseif TEST
BLOCK
:
else
BLOCK
end
switch TEST
case TEST
BLOCK
:
default TEST
BLOCK
end
try
BLOCK
catch
BLOCK
end
for INDEX
BLOCK
end
while TEST
BLOCK
end
until TEST
BLOCK
end
when EVENT
BLOCK
end
def f=(x,y,...)
BLOCK
end
Inline functions are also supported using fat-arrows:
(x,y,...) => {
BLOCK
}
Requires: module:mathjs, module:enums, module:cp
Author: ACMESDS
| Param | Type | Description |
| --- | --- | --- |
| pgm | String \| Array | Script to reduce and execute. Use an Array to bypass default eol-tokenization. |
| blks | Array | Stash fo code blocks; initially []. |
| idx | Number | Current line index to start parsing; initially 0. |
| lang | Object | Language model; see code herein. |
Example (js-reduction)
`js
\\ program
def f=(x,y)
f=x+y;
end
\\ reduces to
def($ctx[1])
\\ with resulting context
[ { test: 'f=(x,y)', code: 'f=x+y\n' } ]
``
Example (js-reduction) js`
\\ program
for i
i1
i2
for j
j1; j2;
while u\u1\end
end
end
\\ reduces to
for($ctx[3])
\\ with resulting context
[
{ test: 'u', code: 'u1\n' },
{ test: 'j', code: 'j1; j2;\nwhile($ctx[1])' },
{ test: 'i', code: 'i1\ni2\nfor($ctx[2])' }
]`
Example (js-reduction) js`
\\ program
a1="this;is;a;test";
\\ reduces to
a1=$ctx[1];
\\ with resulting context
[ 'this;is;a;test' ]`
Example (js-reduction) js`
\\ program
somefn(1,2, \def f=(x,y)
print("x=%f and y=%f",x,y);
end
)
\\ and program
somefn(1,2, \(x,y) => {
print("x=%f and y=%f",x,y);
})
\\ reduces to
def($ctx[2]))
\\ with resulting context
[ 'x=%f and y=%f', { test: 'f=(x,y)', code: 'print($ctx[1],x,y);\n' } ]`
Example (js-reduction) js`
\\ program
def f=(x,y)
f=x+y;
end
disp(f(1,2));
\\ reduces to
def($ctx[1]);disp(f(1,2));
\\ with resulting context
[ { test: 'f=(x,y)', code: 'f=x+y;\n' } ]`
Example (js-reduction) js``
\\ program
def f=([a,b],{x,y})
f=x+y+a+b;
end
disp(f([4,5],{x:10,y:20}));
\\ reduces to
def($ctx[1]);disp(f([4,5],{x:10,y:20}));
\\ with resulting context
[ { test: 'f=([a,b],{x,y})', code: 'f=x+y+a+b;\n' } ]
* MATHJX
* ~saveKeys
* ~scripts
* .conf
* .pca
* .roc
* .snr
* .p0
* .pw
* .wk
* .trigger()
* ~def()
* ~for()
* ~while()
* ~if()
* ~try()
* ~switch()
* ~when()
* ~until()
* ~isNull()
* ~eye()
* ~toMatrix()
* ~toList()
* ~isDefined()
* ~rank()
* ~size()
* ~len()
* ~disp()
* ~print()
* ~plot()
* ~resnet()
* ~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()
* ~rp()
* ~mcmc()
* ~triggerProfile()
* ~coherenceIntervals()
* ~arrivalRates()
* ~estGauss()
* [~oga([Array], [Array], [Function])](#module_MATHJX..oga)
* ~getEv(d, keys)
* ~putEv()
* ~stateSize()
* ~BIC()
* ~draw()
* ~cum()
* ~crf()
* ~propEv()
* ~CMI()
* ~indicate()
* ~boost(cycle, sql, solve, trace, hypo)
* ~svd()
* ~evd()
* ~rng()
* ~rand()
* ~randRot()
* ~proj()
* ~orthoNorm()
* ~any()
* ~all()
* ~MaxFlowMinCut()
* ~ranreg()
* ~degrees()
* ~degree()
* ~nodes()
* ~spectrum()
* ~isoperi()
* ~edges()
* ~clone()
* ~graph()
* ~union()
* ~empty()
* ~ranregs()
* ~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()
MATHJX MATHJX * ~scripts
* .conf
* .pca
* .roc
* .snr
* .p0
* .pw
* .wk
* .trigger()
#### 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
MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX Kind: inner method of MATHJX
Kind: inner method of MATHJX
MATHJX Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
MATHJX MATHJX MATHJX MATHJX 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 MATHJX
| 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) |
MATHJX Kind: inner method of MATHJX
| 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) |
MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX Kind: inner method of MATHJX
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 MATHJX
Kind: inner method of MATHJX
MATHJX MATHJX Kind: inner method of MATHJX
| Param | Description |
| --- | --- |
| [Array] | x word list |
| [Array] | y word list |
| [Function] | s Distance function(gap marker, word) |
Kind: inner method of MATHJX
| Param | Type | Description |
| --- | --- | --- |
| d | Array | data |
| keys | Array | keys into data |
MATHJX MATHJX Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
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 MATHJX
| 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) |
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
MATHJX Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
Kind: inner method of MATHJX
MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX MATHJX * JIMP
* ~$
* ~help
* ~save()
* ~sym()
* ~XX()
JIMP JIMP JIMP JIMP JIMP Feel free to
* submit and status TOTEM issues
* contribute to TOTEM notebooks
* revise TOTEM requirements
* browse TOTEM holdings
* or follow TOTEM milestones
*
© 2012 ACMESDS