math and statistics

Functions Most Likely to Succeed (i.e., be used) – math and statistics

math.sqrt(x) Return the square root of x.
math.pow(x, y) Return x raised to the power y.
*remember that taking fractional power of y will produce the y root of the number: (27,1/3)=3, m.pow(16,1/4)=2
math.factorial(x) “6!” (in general math notation, but not in Python) = 6*5*4*3*2*1= math.factorial(6) = 720; math.factorial(0)=1
math.fsum(iterable) sum of all the numbers in a list or tuple or set
math.isclose(a, b [,rel_tol= tolerance as a % of a] [,abs_tol= numerical difference allowed])
math.pi The mathematical constant π = 3.141592…
statistics.mean() Arithmetic mean (“average”) of data.
statistics.median() Median (middle value) of data.
statistics.mode() Mode (most common value) of discrete data.
statistics.pstdev() Population standard deviation of data.
statistics.pvariance() Population variance of data.

math Summary
https://docs.python.org/3/library/math.html#module-math

Numerical functions

math.ceil(x) x is a float. Return the ceiling of x, the smallest integer greater than or equal to x.
math.copysign(x, y) Return a float with the magnitude (absolute value) of x but the sign of y.
math.fabs(x) Return the absolute value of x.
math.factorial(x) Return x factorial. Raises ValueError if x is not integral or is negative.
math.floor(x) x is a float. Return the floor of x, the largest integer less than or equal to x.
math.fmod(x, y) Return fmod(x, y), as defined by the platform C library. Function fmod() is generally preferred when working with floats, while Python’s x % y is preferred when working with integers.
math.frexp(x) Return the mantissa and exponent of x as the pair (m, e). m is a float and e is an integer such that x == m * 2**e exactly.
math.fsum(iterable) Return an accurate floating point sum of values in the iterable.
math.gcd(a, b) Return the greatest common divisor of the integers a and b. If either a or b is nonzero, then the value of gcd(a, b) is the largest positive integer that divides both a and b.gcd(0, 0) returns 0.
math.isclose(a, b, *, rel_tol=1e-09, abs_tol=0.0) Return True if the values a and b are close to each other and False otherwise.
math.isfinite(x) Return True if x is neither an infinity nor a NaN, and False otherwise. (Note that 0.0 is considered finite.)
math.isinf(x) Return True if x is a positive or negative infinity, and False otherwise.
math.isnan(x) Return True if x is a NaN (not a number), and False otherwise.
math.ldexp(x, i) Return x * (2**i). This is essentially the inverse of function frexp().
math.modf(x) Return the fractional and integer parts of x. Both results carry the sign of x and are floats.
math.trunc(x) Return the Real value x truncated to an Integral (usually an integer). Delegates to x.__trunc__().

Power and logarithmic functions

math.exp(x) Return e**x.
math.expm1(x) Return e**x – 1. For small floats x, the subtraction in exp(x) – 1 can result in a significant loss of precision; the expm1() function provides a way to compute this quantity to full precision:
math.log(x[, base]) With one argument, return the natural logarithm of x (to base e). With two arguments, return the logarithm of x to the given base, calculated as log(x)/log(base).
math.log1p(x) Return the natural logarithm of 1+x (base e).
math.log2(x) Return the base-2 logarithm of x. This is usually more accurate than log(x, 2).
math.log10(x) Return the base-10 logarithm of x. This is usually more accurate than log(x, 10).
math.pow(x, y) Return x raised to the power y.
math.sqrt(x) Return the square root of x.

Trigonometric functions

math.acos(x) Return the arc cosine of x, in radians.
math.asin(x) Return the arc sine of x, in radians.
math.atan(x) Return the arc tangent of x, in radians.
math.atan2(y, x) Return atan(y / x), in radians. The result is between -pi and pi.
math.cos(x) Return the cosine of x radians.
math.hypot(x, y) Return the Euclidean norm, sqrt(x*x + y*y). This is the length of the vector from the origin to point (x, y).
math.sin(x) Return the sine of x radians.
math.tan(x) Return the tangent of x radians.

Angular conversion

math.degrees(x) Convert angle x from radians to degrees.
math.radians(x) Convert angle x from degrees to radians.

Hyperbolic functions Hyperbolic functions are analogs of trigonometric functions that are based on hyperbolas instead of circles.

math.acosh(x) Return the inverse hyperbolic cosine of x.
math.asinh(x) Return the inverse hyperbolic sine of x.
math.atanh(x) Return the inverse hyperbolic tangent of x.
math.cosh(x) Return the hyperbolic cosine of x.
math.sinh(x) Return the hyperbolic sine of x.
math.tanh(x) Return the hyperbolic tangent of x.

Special functions

math.erf(x) Return the (Gauss) error function at x.
math.erfc(x) Return the complementary error function at x.
math.gamma(x) Return the Gamma function at x.
math.lgamma(x) Return the natural logarithm of the absolute value of the Gamma function at x.

Constants

math.pi The mathematical constant π = 3.141592…, to available precision.
math.e The mathematical constant e = 2.718281…, to available precision.
math.tau The mathematical constant τ = 6.283185…, to available precision. Tau is a circle constant equal to 2π,
math.inf A floating-point positive infinity. (For negative infinity, use -math.inf.) Equivalent to the output of float(‘inf’).
math.nan A floating-point “not a number” (NaN) value. Equivalent to the output of float(‘nan’).

statistics summary
https://docs.python.org/3/library/statistics.html#module-statistics

Averages

statistics.mean() Arithmetic mean (“average”) of data.
statistics.harmonic_mean() Harmonic mean of data.
statistics.median() Median (middle value) of data.
statistics.median_low() Low median of data.
statistics.median_high() High median of data.
statistics.median_grouped() Median, or 50th percentile, of grouped data.
statistics.mode() Mode (most common value) of discrete data.

Variance and Deviation

statistics.pstdev() Population standard deviation of data.
statistics.pvariance() Population variance of data.
statistics.stdev() Sample standard deviation of data.
statistics.variance() Sample variance of data.median_high()

exception statistics.StatisticsError