數值與數學模組
**************

本章所描述的模組提供了數值和與數學相關的函式和資料型別。"numbers" 模組
定義了數值型別的抽象階層結構。"math" 和 "cmath" 模組包含了用於浮點數和
複數的各種數學函式。"decimal" 模組支援對十進位數字的精確表示以及任意精
度的算術運算。

本章節包含下列的模組：

* "numbers" --- 數值的抽象基底類別

  * "Number"

  * 數值的階層

    * "Complex"

      * "real"

      * "imag"

      * "conjugate()"

    * "Real"

    * "Rational"

      * "numerator"

      * "denominator"

    * "Integral"

  * 給型別實作者的註記

    * 加入更多數值 ABC

    * 實作算術操作

* "math" --- 數學函式

  * 數論函式

    * "comb()"

    * "factorial()"

    * "gcd()"

    * "isqrt()"

    * "lcm()"

    * "perm()"

  * Floating point arithmetic

    * "ceil()"

    * "fabs()"

    * "floor()"

    * "fma()"

    * "fmod()"

    * "modf()"

    * "remainder()"

    * "trunc()"

  * Floating point manipulation functions

    * "copysign()"

    * "frexp()"

    * "isclose()"

    * "isfinite()"

    * "isinf()"

    * "isnan()"

    * "ldexp()"

    * "nextafter()"

    * "ulp()"

  * Power, exponential and logarithmic functions

    * "cbrt()"

    * "exp()"

    * "exp2()"

    * "expm1()"

    * "log()"

    * "log1p()"

    * "log2()"

    * "log10()"

    * "pow()"

    * "sqrt()"

  * Summation and product functions

    * "dist()"

    * "fsum()"

    * "hypot()"

    * "prod()"

    * "sumprod()"

  * Angular conversion

    * "degrees()"

    * "radians()"

  * Trigonometric functions

    * "acos()"

    * "asin()"

    * "atan()"

    * "atan2()"

    * "cos()"

    * "sin()"

    * "tan()"

  * Hyperbolic functions

    * "acosh()"

    * "asinh()"

    * "atanh()"

    * "cosh()"

    * "sinh()"

    * "tanh()"

  * 特殊函式

    * "erf()"

    * "erfc()"

    * "gamma()"

    * "lgamma()"

  * 常數

    * "pi"

    * "e"

    * "tau"

    * "inf"

    * "nan"

* "cmath" --- 複數的數學函式

  * 轉換到極座標和從極座標做轉換

    * "phase()"

    * "polar()"

    * "rect()"

  * 冪函數和對數函數

    * "exp()"

    * "log()"

    * "log10()"

    * "sqrt()"

  * 三角函數

    * "acos()"

    * "asin()"

    * "atan()"

    * "cos()"

    * "sin()"

    * "tan()"

  * 雙曲函數

    * "acosh()"

    * "asinh()"

    * "atanh()"

    * "cosh()"

    * "sinh()"

    * "tanh()"

  * 分類函式

    * "isfinite()"

    * "isinf()"

    * "isnan()"

    * "isclose()"

  * 常數

    * "pi"

    * "e"

    * "tau"

    * "inf"

    * "infj"

    * "nan"

    * "nanj"

* "decimal" --- 十進位固定點和浮點運算

  * Quick-start Tutorial

  * Decimal objects

    * "Decimal"

      * "adjusted()"

      * "as_integer_ratio()"

      * "as_tuple()"

      * "canonical()"

      * "compare()"

      * "compare_signal()"

      * "compare_total()"

      * "compare_total_mag()"

      * "conjugate()"

      * "copy_abs()"

      * "copy_negate()"

      * "copy_sign()"

      * "exp()"

      * "from_float()"

      * "fma()"

      * "is_canonical()"

      * "is_finite()"

      * "is_infinite()"

      * "is_nan()"

      * "is_normal()"

      * "is_qnan()"

      * "is_signed()"

      * "is_snan()"

      * "is_subnormal()"

      * "is_zero()"

      * "ln()"

      * "log10()"

      * "logb()"

      * "logical_and()"

      * "logical_invert()"

      * "logical_or()"

      * "logical_xor()"

      * "max()"

      * "max_mag()"

      * "min()"

      * "min_mag()"

      * "next_minus()"

      * "next_plus()"

      * "next_toward()"

      * "normalize()"

      * "number_class()"

      * "quantize()"

      * "radix()"

      * "remainder_near()"

      * "rotate()"

      * "same_quantum()"

      * "scaleb()"

      * "shift()"

      * "sqrt()"

      * "to_eng_string()"

      * "to_integral()"

      * "to_integral_exact()"

      * "to_integral_value()"

    * Logical operands

  * Context objects

    * "getcontext()"

    * "setcontext()"

    * "localcontext()"

    * "BasicContext"

    * "ExtendedContext"

    * "DefaultContext"

    * "Context"

      * "clear_flags()"

      * "clear_traps()"

      * "copy()"

      * "copy_decimal()"

      * "create_decimal()"

      * "create_decimal_from_float()"

      * "Etiny()"

      * "Etop()"

      * "abs()"

      * "add()"

      * "canonical()"

      * "compare()"

      * "compare_signal()"

      * "compare_total()"

      * "compare_total_mag()"

      * "copy_abs()"

      * "copy_negate()"

      * "copy_sign()"

      * "divide()"

      * "divide_int()"

      * "divmod()"

      * "exp()"

      * "fma()"

      * "is_canonical()"

      * "is_finite()"

      * "is_infinite()"

      * "is_nan()"

      * "is_normal()"

      * "is_qnan()"

      * "is_signed()"

      * "is_snan()"

      * "is_subnormal()"

      * "is_zero()"

      * "ln()"

      * "log10()"

      * "logb()"

      * "logical_and()"

      * "logical_invert()"

      * "logical_or()"

      * "logical_xor()"

      * "max()"

      * "max_mag()"

      * "min()"

      * "min_mag()"

      * "minus()"

      * "multiply()"

      * "next_minus()"

      * "next_plus()"

      * "next_toward()"

      * "normalize()"

      * "number_class()"

      * "plus()"

      * "power()"

      * "quantize()"

      * "radix()"

      * "remainder()"

      * "remainder_near()"

      * "rotate()"

      * "same_quantum()"

      * "scaleb()"

      * "shift()"

      * "sqrt()"

      * "subtract()"

      * "to_eng_string()"

      * "to_integral_exact()"

      * "to_sci_string()"

  * 常數

    * "MAX_PREC"

    * "MAX_EMAX"

    * "MIN_EMIN"

    * "MIN_ETINY"

    * "HAVE_THREADS"

    * "HAVE_CONTEXTVAR"

  * Rounding modes

    * "ROUND_CEILING"

    * "ROUND_DOWN"

    * "ROUND_FLOOR"

    * "ROUND_HALF_DOWN"

    * "ROUND_HALF_EVEN"

    * "ROUND_HALF_UP"

    * "ROUND_UP"

    * "ROUND_05UP"

  * Signals

    * "Clamped"

    * "DecimalException"

    * "DivisionByZero"

    * "Inexact"

    * "InvalidOperation"

    * "Overflow"

    * "Rounded"

    * "Subnormal"

    * "Underflow"

    * "FloatOperation"

  * Floating-Point Notes

    * Mitigating round-off error with increased precision

    * 特殊值

  * Working with threads

  * Recipes

  * Decimal FAQ

* "fractions" --- 有理數

  * "Fraction"

    * "numerator"

    * "denominator"

    * "as_integer_ratio()"

    * "is_integer()"

    * "from_float()"

    * "from_decimal()"

    * "limit_denominator()"

    * "__floor__()"

    * "__ceil__()"

    * "__round__()"

    * "__format__()"

* "random" --- 生成偽隨機數

  * 簿記函式 (bookkeeping functions)

    * "seed()"

    * "getstate()"

    * "setstate()"

  * 回傳位元組的函式

    * "randbytes()"

  * 回傳整數的函式

    * "randrange()"

    * "randint()"

    * "getrandbits()"

  * 回傳序列的函式

    * "choice()"

    * "choices()"

    * "shuffle()"

    * "sample()"

  * 離散分布

    * "binomialvariate()"

  * 實數分布

    * "random()"

    * "uniform()"

    * "triangular()"

    * "betavariate()"

    * "expovariate()"

    * "gammavariate()"

    * "gauss()"

    * "lognormvariate()"

    * "normalvariate()"

    * "vonmisesvariate()"

    * "paretovariate()"

    * "weibullvariate()"

  * 替代產生器

    * "Random"

      * "seed()"

      * "getstate()"

      * "setstate()"

      * "random()"

      * "getrandbits()"

    * "SystemRandom"

  * 關於 Reproducibility（復現性）的注意事項

  * 範例

  * 使用方案

  * Command-line usage

  * Command-line example

* "statistics" --- 數學統計函式

  * 平均值與中央位置量數

  * 離度 (spread) 的測量

  * 兩個輸入之間的關係統計

  * 函式細節

    * "mean()"

    * "fmean()"

    * "geometric_mean()"

    * "harmonic_mean()"

    * "kde()"

    * "kde_random()"

    * "median()"

    * "median_low()"

    * "median_high()"

    * "median_grouped()"

    * "mode()"

    * "multimode()"

    * "pstdev()"

    * "pvariance()"

    * "stdev()"

    * "variance()"

    * "quantiles()"

    * "covariance()"

    * "correlation()"

    * "linear_regression()"

  * 例外

    * "StatisticsError"

  * "NormalDist" 物件

    * "NormalDist"

      * "mean"

      * "median"

      * "mode"

      * "stdev"

      * "variance"

      * "from_samples()"

      * "samples()"

      * "pdf()"

      * "cdf()"

      * "inv_cdf()"

      * "overlap()"

      * "quantiles()"

      * "zscore()"

  * 範例與錦囊妙計

    * 經典機率問題

    * 用於模擬的蒙地卡羅 (Monte Carlo) 輸入

    * 近似二項分布

    * 單純貝氏分類器 (Naive bayesian classifier)
