Socket
Socket
Sign inDemoInstall

brainsatplay-math

Package Overview
Dependencies
0
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    brainsatplay-math

Math math math


Version published
Maintainers
1
Created

Readme

Source

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.

Keywords

FAQs

Last updated on 12 Oct 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc