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

brainsatplay-math

v0.1.0

Published

Math math math

Downloads

67

Readme

brainsatplay-math

Brains@Play math stuff. Math2 contains all static methods. These get assigned to the main Math object as well as an extension.

This repo will be deprecated at some point when I know where to put all this stuff (if it's even worth keeping later)

  • Math2: Advanced Mathematical Utilities
  • This class provides a comprehensive set of mathematical and statistical functions,
  • vector operations, matrix manipulations, and various utility methods.
  • The methods are static and can be used without instantiating the class.
  • Note: When importing this script, these methods are also assigned to the Math object without conflict.
  • --- Constants ---
    • TWO_PI: Represents 2π.
    • C, G, h, R, Ra, H, kbar, kB, ke, me, mp, mn, P0, T0, p0, Na, y, M0, g0, Re, B, S, Sigma: Various mathematical and physical constants.
  • --- Vector Operations ---
    • vecadd(...vectors): Element-wise addition of vectors.
    • vecmul(...vectors): Element-wise multiplication of vectors.
    • vecsub(vec1, vec2): Subtract vec2 from vec1.
    • vecdiv(numvec, denvec): Element-wise division of numvec by denvec.
    • vecscale(vec, scalar): Scale a vector by a scalar.
    • dot(vec1, vec2): Dot product of two vectors.
    • cross3D(vec1, vec2): Cross product for 3D vectors.
    • magnitude(vec): Compute the magnitude of a vector.
    • distance(point1, point2): Compute the distance between two points.
    • normalize(vec): Normalize a vector.
    • project(vec1, vec2): Project vec1 onto vec2.
    • angleBetween(vec1, vec2): Compute the angle (in radians) between two vectors.
    • sphericalToCartesian(r, theta, phi): Convert spherical coordinates to Cartesian.
    • cartesianToSpherical(x, y, z): Convert Cartesian coordinates to spherical.
    • makeVec(point1, point2): Create a vector from two points.
    • vecaddScalar, vecmulScalar, vecsubScalar, vecdivScalar: Perform operations between a vector and a scalar.
    • midpoint: Compute the midpoint between two points.
    • normalizeSeries: Normalize a series of numbers.
  • --- Matrix Operations ---
    • transpose(mat): Transpose a 2D matrix.
    • matmul(A, B): Multiply two matrices.
    • matscale(mat, scalar): Scale a matrix by a scalar.
    • matadd(A, B): Add two matrices.
    • matsub(A, B): Subtract matrix B from A.
    • inverse(matrix): Compute the inverse of a square matrix.
    • diagonalMatrix(values): Create a diagonal matrix with given values.
    • identityMatrix(size): Create an identity matrix of a given size.
    • getColumn(matrix, col): Extract a column from a matrix.
    • clone(mat): Create a deep copy of a matrix.
    • qrDecomposition(matrix): Perform QR decomposition on a matrix.
    • householderMatrix: Generate a Householder matrix from a vector.
    • inverse: Compute the inverse of a matrix.
    • column: Extract a column from a matrix.
    • flatten_vector: Flatten a vector.
    • squared_difference: Compute the squared difference between two vectors.
    • shift_deflate: Perform shift deflate operation on a matrix.
    • eigenvalue_of_vector: Compute the eigenvalue of a vector for a matrix.
    • svdSimultaneousPowerIteration: Compute the SVD using simultaneous power iteration.
    • reshape: Reshape an array to a given shape.
  • --- Statistical Functions ---
    • mean(arr): Compute the mean of an array.
    • median(data): Compute the median of an array.
    • mode(arr): Compute the mode of an array.
    • std(arr, mean): Compute the standard deviation of an array.
    • variance(arr): Compute the variance of an array.
    • coeffVariation(arr, populationMean): Compute the coefficient of variance.
    • skewness(arr): Compute the skewness of an array.
    • kurtosis(arr): Compute the kurtosis of an array.
    • chiSquareTest(observed, expected): Perform a chi-square goodness of fit test.
    • percentile(arr, p): Compute the p-th percentile of an array.
    • interquartileRange(arr): Compute the interquartile range of an array.
    • range(data): Compute the range (max - min) of an array.
    • relError(actual, forecast): Compute the relative error between actual and forecast values.
    • zscore(arr): Compute the z-scores of an array.
    • covariance(arr1, arr2): Compute the covariance between two arrays.
    • correlationCoeff(arr1, arr2): Compute the correlation coefficient between two arrays.
    • informationEntropy: Compute the information entropy of an array.
    • coeffDetermination: Compute the coefficient of determination between observed and expected values.
    • simpleLinearRegression: Perform simple linear regression on x and y coordinates.
    • expectedValue: Compute the expected value of samples.
    • originMoment: Compute the origin moment of samples.
    • centralMoment: Compute the central moment of samples.
    • linearDiscriminantAnalysis: Perform linear discriminant analysis on samples.
    • decompose: Decompose a signal.
    • idwt: Inverse discrete wavelet transform.
    • dwtMaxLevel: Compute the maximum level of discrete wavelet transform.
    • minMaxScaler: Scale data to a min-max range.
    • garroteThreshold: Apply garrote thresholding to data.
    • covVec: Compute the covariance of two vectors.
    • cov1d, cov2d, cov3d, covNd: Compute the covariance for 1D, 2D, 3D, and N-dimensional data.
    • eigens2x2, eigenvectors2x2: Compute the eigenvalues and eigenvectors for a 2x2 matrix.
    • fastpca2d: Perform fast PCA for 2D data.
    • crosscorrelation, autocorrelation, autocorrelation2d, autocorrelation2dNormalized, crosscorrelation2d, crosscorrelation2dNormalized, correlograms: Various correlation methods.
    • sma: Compute the simple moving average.
    • reduceArrByFactor: Reduce an array by a given factor.
    • makeArr: Create an array with linearly spaced values.
    • autoscale: Autoscale an array.
    • absmax: Compute the absolute maximum of an array.
    • downsample, upsample, dyadicUpsample, resample: Various sampling methods.
    • isExtrema, isCriticalPoint: Check for extrema or critical points in an array.
    • peakDetect: Detect peaks in an array.
    • getPeakThreshold: Compute the threshold for peak detection.
    • circularBuffer: Implement a circular buffer.
  • --- Utility Methods ---
    • HSLToRGB(h, s, l, scalar): Convert HSL to RGB.
    • genSineWave(): Generate a sine wave.
    • linspace(start, end, num): Generate linearly spaced values between start and end.
    • lerp(v0, v1, t): Linear interpolation between v0 and v1.
    • pad(arr, pad, padValue): Pad an array with a given value.
    • flatten(arr): Flatten a multi-dimensional array.
    • sum(arr): Compute the sum of an array's elements.
    • histogram(arr, binSize): Compute a histogram of an array.
    • normalDistribution(samples, normalize): Generate a normal distribution from samples.
  • --- Advanced Mathematical Methods ---
    • eigens(mat): Compute the eigenvalues of a matrix.
    • pca(mat): Principal Component Analysis.
    • dft(arr): Discrete Fourier Transform.
    • svd(A): Singular Value Decomposition of a matrix.
    • power_iteration(A): Power iteration method for eigenvalue computation.
    • quadraticFormula(a, b, c): Solve a quadratic equation.
    • newtonsMethod1D(foo): Newton's method for root finding in 1D.
    • integral(func, range): Compute the integral of a function over a range.
    • dintegral(func, range, stepx, stepy): Approximate the double integral (volume under a surface) in 3D space using the provided function and range.
    • tintegral(func, range, stepx, stepy, stepz): Approximate the triple integral in 4D space using the provided function and range.
    • pintegral(func, range, stepx): Approximate the path integral (length of a curve) in 2D space using the provided function and range.
    • pathIntegral2D(xFunc, yFunc, range, stepx, stepy): Approximate the path integral (length of a curve) in 2D space using parametric functions for x and y.
    • pathIntegral3D(xFunc, yFunc, zFunc, range, stepx, stepy, stepz): Approximate the path integral (length of a curve) in 3D space using parametric functions for x, y, and z.
  • --- Filters and Kernels ---
    • imgkernels: Collection of image processing kernels.
    • conv1D(s, kernel): 1D convolution.
    • conv2D(matrix, kernel): 2D convolution.
    • convN(matrix, kernel): N-dimensional convolution
    • p300: Compute the P300 component of event-related potentials.
    • waveletFiltering: Filter a signal using wavelets.
    • dec_lo,dec_hi,rec_lo,rec_hi: sym4 wavelet lowpass/highpass filters prepicked for motion artifacts
  • For detailed parameter descriptions and usage, refer to the individual method documentation.