/** * Round down a number to specific precision. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/floor) * @param x a number * @param pre to precision (1) */ declare function floor(x: number, pre?: number): number; /** * Round up a number to specific precision. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/ceil) * @param x a number * @param pre to precision [1] */ declare function ceil(x: number, pre?: number): number; /** * Round a number to specific precision. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/round) * @param x a number * @param pre to precision [1] */ declare function round(x: number, pre?: number): number; /** * Perform floor-divison of two numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/floorDiv) * @param x divisor * @param y dividend * @returns โŒŠx/yโŒ‹ */ declare function floorDiv(x: number, y: number): number; /** * Perform ceiling-divison of two numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/ceilDiv) * @param x divisor * @param y dividend * @returns โŒˆx/yโŒ‰ */ declare function ceilDiv(x: number, y: number): number; /** * Perform rounded-divison of two numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/roundDiv) * @param x divisor * @param y dividend * @returns [x/y] */ declare function roundDiv(x: number, y: number): number; /** * Find the remainder of x/y with sign of x (truncated division). * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/rem) * @param x dividend * @param y divisor * @returns trunc(x % y) */ declare function rem(x: number, y: number): number; /** * Find the remainder of x/y with sign of y (floored division). * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/mod) * @param x dividend * @param y divisor * @returns floor(x % y) */ declare function mod(x: number, y: number): number; /** * Find the remainder of x/y with +ve sign (euclidean division). * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/modp) * @param x dividend * @param y divisor * @returns n>0: floor(x % y), n<0: ceil(x % y) */ declare function modp(x: number, y: number): number; /** * Constrain a number within a minimum and a maximum value. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/constrain) * @param x a number * @param min minimum value * @param max maximum value * @returns xmax: max, x */ declare function constrain(x: number, min: number, max: number): number; /** * Normalize a number from its current range into a value between 0 and 1. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/normalize) * @param x a number * @param r lower bound of current range * @param R upper bound of current range * @returns โˆˆ [0, 1] */ declare function normalize(x: number, r: number, R: number): number; /** * Re-map a number from one range to another. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/remap) * @param x a number * @param r lower bound of current range * @param R upper bound of current range * @param t lower bound of target range * @param T upper bound of target range * @returns โˆˆ [ymin, ymax] */ declare function remap(x: number, r: number, R: number, t: number, T: number): number; /** * Linearly interpolate a number between two numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/lerp) * @param x start number * @param y stop number * @param t interpolant โˆˆ [0, 1] * @returns โˆˆ [x, y] */ declare function lerp(x: number, y: number, t: number): number; /** * Check if a number is a power-of-n. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/isPow) * @param x a number * @param n base * @returns nโฑ = x? | i = +ve integer */ declare function isPow(x: number, n: number): boolean; /** * Find largest power-of-n less than or equal to given number. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/prevPow) * @param x a number * @param n base * @returns nโฑ | nโฑ โ‰ค x and nโฑ > x/n */ declare function prevPow(x: number, n: number): number; /** * Find smallest power-of-n greater than or equal to given number. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/nextPow) * @param x a number * @param n base * @returns nโฑ | nโฑ โ‰ฅ x and nโฑ < n*x */ declare function nextPow(x: number, n: number): number; /** * Find the nth root of a number (โฟโˆš). * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/root) * @param x a number * @param n root * @returns โฟโˆšx */ declare function root(x: number, n: number): number; /** * Find the logarithm of a number with a given base. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/log) * @param x a number * @param b logarithm base [e] * @returns log_b (x) */ declare function log(x: number, b?: number): number; /** * List all divisors of a number, except itself. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/properDivisors) * @param x a number * @returns proper divisors (factors) */ declare function properDivisors(x: number): number[]; /** * Sum all proper divisors of a number. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/aliquotSum) * @param x a number * @returns ฮฃdแตข | dแตข is a divisor of x and โ‰ x */ declare function aliquotSum(x: number): number; /** * Find the least prime number which divides a number. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/minPrimeFactor) * @param x a number * @returns least prime factor */ declare function minPrimeFactor(x: number): number; /** * Find the greatest prime number which divides a number. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/maxPrimeFactor) * @param x a number * @returns greatest prime factor */ declare function maxPrimeFactor(x: number): number; /** * Find the prime factors of a number. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/primeFactors) * @param x a number * @returns [fโ‚€, fโ‚, ...] | fแตข divides x and is prime */ declare function primeFactors(x: number): number[]; /** * Find the prime factors and respective exponents of a number. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/primeExponentials) * @param x a number * @returns [[fโ‚€, eโ‚€], [fโ‚, eโ‚], ...] | fแตข is a prime factor of x and eแตข is its exponent */ declare function primeExponentials(x: number): [number, number][]; /** * Examine if number is prime. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/isPrime) * @param x a number * @returns is divisible by 1 and itself only? */ declare function isPrime(x: number): boolean; /** * Find the greatest common divisor of numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/gcd) * @param xs a list of numbers * @returns gcd(xโ‚, xโ‚‚, ...) */ declare function gcd(...xs: number[]): number; /** * Find the least common multiple of numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/lcm) * @param xs a list of numbers * @returns lcm(xโ‚, xโ‚‚, ...) */ declare function lcm(...xs: number[]): number; /** * Find the factorial of a number. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/factorial) * @param n a number * @param k denominator factorial [0] * @returns P(n, k); k=0: n!, k>0: n!/k! */ declare function factorial(n: number, k?: number): number; /** * Find the number of ways to choose k elements from a set of n elements. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/binomial) * @param n elements in source set * @param k elements in choose set * @returns C(n, k) */ declare function binomial(n: number, k: number): number; /** * Find the number of ways to put n objects in m bins (n=sum(kแตข)). * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/multinomial) * @param ks objects per bin (kแตข) * @returns n!/(kโ‚!kโ‚‚!...) | n=sum(kแตข) */ declare function multinomial(...ks: number[]): number; /** * Convert radians to degrees. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/degrees) * @param x radians * @returns 2ฯ€ โ†’ 360 */ declare function degrees(x: number): number; /** * Convert degrees to radians. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/radians) * @param x degrees * @returns 360 โ†’ 2ฯ€ */ declare function radians(x: number): number; /** * Find the sum of numbers (ฮฃ). * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/sum) * @param xs a list of numbers * @returns ฮฃxแตข */ declare function sum(...xs: number[]): number; /** * Find the product of numbers (โˆ). * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/product) * @param xs a list of numbers * @returns โˆxแตข */ declare function product(...xs: number[]): number; /** * Find the value separating the higher and lower halves of numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/median) * @param xs a list of numbers * @returns xโ‚˜ | sort(xs) = [..., xโ‚˜, ...] */ declare function median(...xs: number[]): number; /** * Find the values that appear most often. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/modes) * @param xs a list of numbers * @returns [xโ‚˜โ‚, xโ‚˜โ‚‚, ...] | count(xโ‚˜แตข) โ‰ฅ count(xแตข) โˆ€ xแตข โˆˆ xs */ declare function modes(...xs: number[]): number[]; /** * Find the smallest and largest values. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/range) * @param xs a list of numbers * @returns [min(xs), max(xs)] */ declare function range(...xs: number[]): [number, number]; /** * Find the mean of squared deviation of numbers from its mean. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/variance) * @param xs a list of numbers * @returns ฯƒยฒ = E[(xs - ยต)ยฒ] | ยต = mean(xs) */ declare function variance(...xs: number[]): number; /** * Find the average of numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/arithmeticMean) * @param xs a list of numbers * @returns ฮฃxแตข/n | n = size(xs) */ declare function arithmeticMean(...xs: number[]): number; /** * Find the geometric mean of numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/geometricMean) * @param xs a list of numbers * @returns โฟโˆš(โˆxแตข) | n = size(xs) */ declare function geometricMean(...xs: number[]): number; /** * Find the harmonic mean of numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/harmonicMean) * @param xs a list of numbers * @returns n/ฮฃ(1/xแตข) | n = size(xs) */ declare function harmonicMean(...xs: number[]): number; /** * Find the quadriatic mean of numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/quadriaticMean) * @param xs a list of numbers * @returns โˆš(ฮฃxแตขยฒ)/n | n = size(xs) */ declare function quadriaticMean(...xs: number[]): number; /** * Find the cubic mean of numbers. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/cubicMean) * @param xs a list of numbers * @returns ยณโˆš(ฮฃxแตขยณ)/n | n = size(xs) */ declare function cubicMean(...xs: number[]): number; /** * Calculate the magnitude (length) of a vector. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/magnitude) * @param xs vector ([x, y, z, ...]) * @returns โˆš(xยฒ + yยฒ + zยฒ) */ declare function magnitude(xs: number[]): number; /** * Calculate the distance between two points. * [๐Ÿ“˜](https://github.com/nodef/extra-math/wiki/distance) * @param xs first point ([x, y, z, ...]) * @param ys second point ([x, y, z, ...]) * @returns โˆš(ฮ”xยฒ + ฮ”yยฒ + ฮ”zยฒ) */ declare function distance(xs: number[], ys: number[]): number; export { properDivisors as aliquotParts, aliquotSum, arithmeticMean, binomial, ceil, ceilDiv, constrain as clamp, constrain, cubicMean, degrees, distance, factorial, floor, floorDiv, gcd, geometricMean, maxPrimeFactor as greatestPrimeFactor, harmonicMean, gcd as hcf, isPow, isPrime, lcm, minPrimeFactor as leastPrimeFactor, lerp, log, magnitude, remap as map, maxPrimeFactor, arithmeticMean as mean, median, minPrimeFactor, mod, modes, modp, multinomial, nextPow, normalize as norm, normalize, prevPow, primeExponentials, primeFactors, product, properDivisors, quadriaticMean, radians, range, rem, remap, root, quadriaticMean as rootMeanSquare, round, roundDiv, sum, variance };