npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@totemorg/man

v2.30.0

Published

matrix manipulator

Downloads

183

Readme

MAN

Extends MathJX with various AI/ML methods:

See the Program Reference for usage 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

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

MAN

Extend mathjs script with mathjx script and various numerical methods.

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) 
);	

MATHJX

Reduce a mathjx-script to a mathjs-script using the following language model:

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)

\\ 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)

\\ 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)

\\ program
	a1="this;is;a;test";
\\ reduces to
	a1=$ctx[1];
\\ with resulting context
		[ 'this;is;a;test' ]

Example (js-reduction)

\\ 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)

\\ 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)

\\ 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

Kind: inner property of MATHJX

MATHJX~scripts

Kind: inner property of MATHJX

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~def()

Kind: inner method of MATHJX

MATHJX~for()

Kind: inner method of MATHJX

MATHJX~while()

Kind: inner method of MATHJX

MATHJX~if()

Kind: inner method of MATHJX

MATHJX~try()

Kind: inner method of MATHJX

MATHJX~switch()

Kind: inner method of MATHJX

MATHJX~when()

Kind: inner method of MATHJX

MATHJX~until()

Kind: inner method of MATHJX

MATHJX~isNull()

Kind: inner method of MATHJX

MATHJX~eye()

Kind: inner method of MATHJX

MATHJX~toMatrix()

Return MathJS tensor handle.

Kind: inner method of MATHJX

MATHJX~toList()

Return JS tensor handle.

Kind: inner method of MATHJX

MATHJX~isDefined()

Kind: inner method of MATHJX

MATHJX~rank()

Return rank of x.

Kind: inner method of MATHJX

MATHJX~size()

Return size of x.

Kind: inner method of MATHJX

MATHJX~len()

Return length of x.

Kind: inner method of MATHJX

MATHJX~disp()

Kind: inner method of MATHJX

MATHJX~print()

Kind: inner method of MATHJX

MATHJX~plot()

Kind: inner method of MATHJX

MATHJX~resnet()

Kind: inner method of MATHJX

MATHJX~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 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~train()

Kind: inner method of MATHJX

MATHJX~predict(cls, use, x, y, solve, cb)

Return predicted labels y given a list x of feature vectors.

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~qda_train()

Kind: inner method of MATHJX

MATHJX~qda_predict()

Kind: inner method of MATHJX

MATHJX~beta_train()

Kind: inner method of MATHJX

MATHJX~beta_predict()

Kind: inner method of MATHJX

MATHJX~rnn_train()

Kind: inner method of MATHJX

MATHJX~rnn_predict()

Kind: inner method of MATHJX

MATHJX~ann_train()

Kind: inner method of MATHJX

MATHJX~ann_predict()

Kind: inner method of MATHJX

MATHJX~dnn_train()

Kind: inner method of MATHJX

MATHJX~dnn_predict()

Kind: inner method of MATHJX

MATHJX~dhs_train()

Kind: inner method of MATHJX

MATHJX~dhs_predict()

Kind: inner method of MATHJX

MATHJX~lda_train()

Kind: inner method of MATHJX

MATHJX~lda_predict()

Kind: inner method of MATHJX

MATHJX~ror_train()

Kind: inner method of MATHJX

MATHJX~ror_predict()

Kind: inner method of MATHJX

MATHJX~dtr_train()

Kind: inner method of MATHJX

MATHJX~dtr_predict()

Kind: inner method of MATHJX

MATHJX~raf_train()

Kind: inner method of MATHJX

MATHJX~raf_predict()

Kind: inner method of MATHJX

MATHJX~nab_train()

Kind: inner method of MATHJX

MATHJX~nab_predict()

Kind: inner method of MATHJX

MATHJX~som_train()

Kind: inner method of MATHJX

MATHJX~som_predict()

Kind: inner method of MATHJX

MATHJX~ols_train()

Kind: inner method of MATHJX

MATHJX~ols_predict()

Kind: inner method of MATHJX

MATHJX~svm_train()

Kind: inner method of MATHJX

MATHJX~svm_predict()

Kind: inner method of MATHJX

MATHJX~lrm_train()

Kind: inner method of MATHJX

MATHJX~lrm_predict()

Kind: inner method of MATHJX

MATHJX~knn_train()

Kind: inner method of MATHJX

MATHJX~knn_predict()

Kind: inner method of MATHJX

MATHJX~pls_train()

Kind: inner method of MATHJX

MATHJX~pls_predict()

Kind: inner method of MATHJX

MATHJX~rp()

Kind: inner method of MATHJX

MATHJX~mcmc()

Markov Chain Monte Carlo process.

Kind: inner method of MATHJX

MATHJX~triggerProfile()

Uses the Paley-Wiener Theorem to return the trigger function in a Poisson counting process.

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

MATHJX~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 MATHJX

MATHJX~arrivalRates()

Kind: inner method of MATHJX

MATHJX~estGauss()

Kind: inner method of MATHJX

MATHJX~oga([Array], [Array], [Function])

Neddleman-Wunch optimal global alignment.

Kind: inner method of MATHJX

| Param | Description | | --- | --- | | [Array] | x word list | | [Array] | y word list | | [Function] | s Distance function(gap marker, word) |

MATHJX~getEv(d, keys)

Get Event from event network.

Kind: inner method of MATHJX

| Param | Type | Description | | --- | --- | --- | | d | Array | data | | keys | Array | keys into data |

MATHJX~putEv()

Kind: inner method of MATHJX

MATHJX~stateSize()

Kind: inner method of MATHJX

MATHJX~BIC()

Return BIC score for specified Bayesian belief network.

Kind: inner method of MATHJX

MATHJX~draw()

Draw deviate from a specified distribution.

Kind: inner method of MATHJX

MATHJX~cum()

Cummulative sum.

Kind: inner method of MATHJX

MATHJX~crf()

Draw Bayesian network deviates with specifed Conditional Random Field

Kind: inner method of MATHJX

MATHJX~propEv()

Propagate evidents in a Bayesian belief network.

Kind: inner method of MATHJX

MATHJX~CMI()

Conditional mutual information for Baysian belief network.

Kind: inner method of MATHJX

MATHJX~indicate()

Returns indicator of a test vector.

Kind: inner method of MATHJX

MATHJX~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 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) |

MATHJX~svd()

Returns singular value decomposition of a real matrix A.

Kind: inner method of MATHJX

MATHJX~evd()

Returns eigen value decomposition of a real matrix A.

Kind: inner method of MATHJX

MATHJX~rng()

Returns range from min to max in N steps.

Kind: inner method of MATHJX

MATHJX~rand()

MxN random matrix

Kind: inner method of MATHJX

MATHJX~randRot()

KxK random rotation matrix

Kind: inner method of MATHJX

MATHJX~proj()

Return vector projection.

Kind: inner method of MATHJX

MATHJX~orthoNorm()

Kind: inner method of MATHJX

MATHJX~any()

Return true is any items true.

Kind: inner method of MATHJX

MATHJX~all()

Returns true is all items true.

Kind: inner method of MATHJX

MATHJX~MaxFlowMinCut()

Contruct max-flow-min-cuts for specified graph.

Kind: inner method of MATHJX

MATHJX~ranreg()

Return an adjaceny matrix for a random n-node, d-regular graph.

Kind: inner method of MATHJX

MATHJX~degrees()

Return node degress for graph with adjaceny matrix A.

Kind: inner method of MATHJX

MATHJX~degree()

Return graph degree given its adjacency matgrix A.

Kind: inner method of MATHJX

MATHJX~nodes()

Return node of a graph with adjacency matrix A.

Kind: inner method of MATHJX

MATHJX~spectrum()

Return eigen spectrum of a graph with adjacency magtrix A.

Kind: inner method of MATHJX

MATHJX~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 MATHJX

MATHJX~edges()

Return edges E of a graph whose adjacency matrix is A.

Kind: inner method of MATHJX

MATHJX~clone()

Clone a graph given its adjacency matrix A.

Kind: inner method of MATHJX

MATHJX~graph()

Return graph G (nodes V, edges E, adjacency matrix A) given its adjacency matrix A.

Kind: inner method of MATHJX

MATHJX~union()

Return graph composition of two graphs with adjacency matricies A and B.

Kind: inner method of MATHJX

MATHJX~empty()

Return an unconnected empty graph having N nodes.

Kind: inner method of MATHJX

MATHJX~ranregs()

Callback cb with random n-node, d[i]-regular graphs given the desired number of random permutations m[i].

Kind: inner method of MATHJX

MATHJX~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 MATHJX

MATHJX~dht()

Returns discrete Hilbert transform of an odd length array f

Kind: inner method of MATHJX

MATHJX~dft()

Returns unnormalized dft/idft of an odd length, real or complex array F.

Kind: inner method of MATHJX

MATHJX~pwrem()

Returns paley-weiner remainder given zeros z in complex UHP at frequencies nu = [ -f0, ... +f0 ] [Hz]

Kind: inner method of MATHJX

MATHJX~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 MATHJX

MATHJX~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 MATHJX

MATHJX~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 MATHJX

MATHJX~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 MATHJX

MATHJX~udev()

Returns uniform random deviate on [0...a]

Kind: inner method of MATHJX

MATHJX~expdev()

Returns exp random deviate with prescribed mean a

Kind: inner method of MATHJX

MATHJX~cumsum()

Returns cummulative sum of x.

Kind: inner method of MATHJX

MATHJX~conf()

Kind: inner method of MATHJX

MATHJX~tolAtConf()

Kind: inner method of MATHJX

MATHJX~tolsAtConf()

Kind: inner method of MATHJX

MATHJX~loggamma()

Kind: inner method of MATHJX

MATHJX~beta()

Kind: inner method of MATHJX

MATHJX~cumbeta()

Kind: inner method of MATHJX

MATHJX~sinc()

Kind: inner method of MATHJX

MATHJX~rect()

Kind: inner method of MATHJX

MATHJX~tri()

Kind: inner method of MATHJX

MATHJX~negexp()

Kind: inner method of MATHJX

MATHJX~lorenzian()

Kind: inner method of MATHJX

MATHJX~zeta()

Kind: inner method of MATHJX

MATHJX~infer()

Kind: inner method of MATHJX

MATHJX~mle()

Kind: inner method of MATHJX

MATHJX~mvn()

Kind: inner method of MATHJX

MATHJX~lfa()

Kind: inner method of MATHJX

MATHJX~lma()

Kind: inner method of MATHJX

MATHJX~rnn()

Kind: inner method of MATHJX

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~XX()

Kind: inner method of JIMP

Contacting, Contributing, Following

Feel free to

License

MIT


© 2012 ACMESDS