Metadata-Version: 2.5
Name: math_stats_raibeena
Version: 0.1.7
Summary: ตัวอย่าง Python Package สำหรับการคำนวณเมทริกซ์และสถิติพื้นฐาน
Project-URL: homepage, https://github.com/username/math_stats
Project-URL: documentation, https://github.com/username/math_stats#readme
Project-URL: repository, https://github.com/username/math_stats.git
Project-URL: Bug Tracker, https://github.com/username/math_stats/issues
Author-email: Raibeena <Raibeena.ye@mail.wu.ac.th>
License: MIT
License-File: LICENSE
Keywords: matrices,statistic
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown

# math_stats_raibeena

---
# คำอธิบาย
Python Package สำหรับการคำนวณเมทริกซ์และสถิติพื้นฐาน 
---

# Description

แพ็กเกจนี้พัฒนาขึ้นเพื่อใช้ในการคำนวณ ตรวจสอบ และวิเคราะห์ทางคณิตศาสตร์เกี่ยวกับเมทริกซ์ เวกเตอร์ และสถิติพื้นฐานเชิงลึก รองรับการประมวลผลเชิงวัตถุ (OOP), การส่งออกข้อมูล (File I/O) และการวิเคราะห์ข้อมูลทางสถิติ ประกอบด้วย 2 โมดูลหลัก:

* *matrix* : คำนวณทางพีชคณิตเชิงเส้น (Linear Algebra) 
รองรับการบวกเวกเตอร์ (vector_add), การดอตผลิตภัณฑ์ (dot_product), การทรานสโพสเมทริกซ์ (matrix_transpose), การหาผลรวมแนวทแยง (matrix_trace) และการคำนวณดีเทอร์มิแนนต์ของเมทริกซ์ขนาด 2x2 (det_2x2)
* *statistic* : วิเคราะห์และคำนวณค่าทางสถิติพื้นฐาน 
รองรับการหาค่าเฉลี่ยเลขคณิต (mean), ค่าความแปรปรวน (variance), ส่วนเบี่ยงเบนมาตรฐาน (std_dev), การแปลงเป็นค่ามาตรฐาน (z_score) และการคำนวณค่าความแปรปรวนร่วมระหว่างสองตัวแปร (covariance)
# Description

The **`math_stats_raibeena`** package is a Python library designed for computing, validating, and analyzing mathematical and statistical data. The package is structured into two core modules—**`matrix`** and **`statistic`**—covering seven technical domains:

---

### Module 1: `matrix`
Focuses on linear algebra, vector operations, advanced OOP inheritance, and spatial visualizations.

* **Vector & Matrix Operations:** Performs core linear algebra calculations, vector norms, orthogonal checks, and matrix transformations.
* **Object-Oriented Programming (OOP):**
  * **Classes & Operators:** Custom `Vector` classes with operator overloading (`__add__`).
  * **Inheritance Models:** Features Single (`Vector2D`), Hierarchical (`Vector3D`), Multilevel (`UnitVector2D`), Multiple (`DescribableVector2D`), and Mixin (`Describable`) patterns.
* **Algorithms:** Implements recursive functions for linear algebra problems (`determinant_recursive`).
* **Scientific Integration & Visualization:**
  * **NumPy:** High-performance matrix multiplications (`matrix_multiply_numpy`).
  * **Visualization:** 2D spatial vector plots via Matplotlib (`plot_vector_2d`) and 3D vector fields via PyVista (`plot_vectors_3d_pyvista`).

---

### Module 2: `statistic`
Focuses on statistical analysis, data processing, file I/O, error handling, and interactive data visualization.

* **Data Structures & Functions:**
  * **Formatting & Structures:** String/currency formatting (`format_currency`) and structural summaries across Lists, Tuples, Dictionaries, and Sets (`summarize_data_structures`).
  * **Function Arguments:** Flexible parameter wrappers using Positional, Keyword, Default, and `*args`/`**kwargs` (`calculate_total_stats`).
* **Algorithms & Benchmarking:**
  * **Recursion & Dynamic Programming:** Combinatorics (`factorial_recursive`) and memoization (`fibonacci_memoized`).
  * **Benchmarking:** Execution speed comparisons across statistical routines (`compare_statistic_algorithms`).
* **Data Management (I/O & Errors):**
  * **File I/O:** Serializes and loads statistical summaries via JSON (`save_summary_json`, `load_summary_json`).
  * **Exception Handling:** Custom exceptions (`InvalidDataError`) and defensive execution wrappers (`safe_mean`).
* **Scientific Libraries Integration:**
  * **Pandas & SciPy:** Tabular DataFrames (`create_summary_dataframe`) and probability density fitting (`fit_normal_scipy`).
  * **SymPy & Advanced Engines:** Symbolic equation solvers (`solve_symbolic_system`) and high-precision engines (SageMath / PARI-GP / GMPY2).
* **Data Visualization:**
  * **Statistical & Interactive Charts:** Distribution plots via Seaborn (`plot_distribution_seaborn`) and interactive scatter plots via Plotly (`plot_interactive_scatter_plotly`).
  * **Network Graphs:** Matrix-based network graph visualizations via NetworkX (`plot_matrix_graph`).

---

---

# การใช้งาน
การติดตั้ง(Installation)
You can install package from Pypi :
```
pip install math-stats-raibeena
```
# PACKAGE

```
import math_stats_raibeena as pkg

# Module 1: matrices

print(pkg.vector_add([1, 2], [3, 4]))                                  # output: [4, 6]
print(pkg.scalar_multiply(2, [1, 2, 3]))                               # output: [2, 4, 6]
print(pkg.dot_product([1, 2, 3], [4, 5, 6]))                           # output: 32
print(pkg.vector_norm([3, 4]))                                         # output: 5.0
print(pkg.matrix_rank([[1, 2], [2, 4]]))                               # output: 1
print(pkg.is_linearly_independent([[1, 0], [0, 1]]))                   # output: True
print(pkg.is_orthogonal([1, 0], [0, 1]))                               # output: True

# --- Recursive function ---
print(pkg.determinant_recursive([[6, 1, 1], [4, -2, 5], [2, 8, 7]]))   # output: -306

# --- OOP: Class, Magic methods, Inheritance ---
v1, v2 = pkg.Vector([1, 2, 3]), pkg.Vector([4, 5, 6])
print(v1 + v2)                                                         # output: Vector([5, 7, 9])

v2d = pkg.Vector2D(3, 4)
print(v2d.norm())                                                      # output: 5.0

v3d = pkg.Vector3D(1, 2, 3)                                            # hierarchical inheritance
print(v3d)                                                             # output: Vector([1, 2, 3])

uv = pkg.UnitVector2D(3, 4)                                            # multilevel inheritance
print(uv.is_unit())                                                    # output: True

dv = pkg.DescribableVector2D(1, 1)                                     # multiple inheritance
print(dv.describe())                                                   # output: เวกเตอร์ 2 มิติ: [1, 1]

duv = pkg.DescribableUnitVector2D(3, 4)                                # hybrid inheritance
print(duv.is_unit(), duv.describe())

class MyVector(pkg.Vector, pkg.Describable):
    pass

mv = MyVector([1, 2])
print(mv.describe())                                                   # output: เวกเตอร์ 2 มิติ: [1, 2]

# --- Numpy ---
print(pkg.matrix_multiply_numpy([[1, 2], [3, 4]], [[5, 6], [7, 8]]))   # output: [[19, 22], [43, 50]]

# --- Data Visualization: Matplotlib, PyVista ---
pkg.plot_vector_2d([3, 4], "vector.png")
pkg.plot_vectors_3d_pyvista([[1, 0, 0], [0, 1, 0]], "vectors3d.png")   # needs pyvista installed
import pyvista as pv


# ==============================================================================

# Module 2: statistic
import sys
sys.stdout.reconfigure(encoding='utf-8')

print(pkg.mean([10, 20, 30, 40, 50]))                                  # output: 30.0
print(pkg.median([10, 20, 30, 40, 50]))                                # output: 30.0
print(pkg.mode([10, 20, 20, 30, 40]))                                  # output: [20]
print(pkg.variance([10, 20, 30, 40, 50]))                              # output: 250.0
print(pkg.std_dev([10, 20, 30, 40, 50]))                               # output: 15.811388300841896
print(pkg.z_score(45, [10, 20, 30, 40, 50]))                           # output: 0.9486832980505138

# --- String Processing ---
print(pkg.format_currency(1234.5))                                     # output: ฿1,234.50

# --- Exception Handling ---
try:
    raise pkg.InvalidDataError("ชุดข้อมูลต้องไม่เป็นค่าว่าง")
except pkg.InvalidDataError as e:
    print(e)                                                           # output: ชุดข้อมูลต้องไม่เป็นค่าว่าง

print(pkg.safe_mean([]))                                               # prints an error message, returns None

# --- Data Structures: dict, tuple, set, list ---
holdings = {"A": [10, 20], "B": [30, 40]}
summary = pkg.summarize_data_structures(holdings)
print(summary)                                                         # output: {'unique_set': {10, 20, 30, 40}, ...}

# --- Function Arguments: Positional, Keyword, Default, Variable-length ---
print(pkg.calculate_total_stats(10, 20, 30, scale=2.0, extra_bonus=5))

# --- Pandas ---
print(pkg.create_summary_dataframe(holdings))

# --- SciPy ---
print(pkg.fit_normal_scipy([1, 2, 3, 4, 5]))                           # output: (3.0, 1.4142135623730951)

# --- SymPy ---
print(pkg.solve_symbolic_system(["x + y - 5", "x - y - 1"], ["x", "y"])) # output: {x: 3, y: 2}

# --- File I/O ---
pkg.save_summary_json({"mean": 30.0}, "summary.json")
print(pkg.load_summary_json("summary.json"))                           # output: {'mean': 30.0}

# --- Data Visualization: Matplotlib, Seaborn ---
pkg.plot_distribution_seaborn([10, 20, 20, 30, 40, 50], "trend.png")

# --- Data Visualization: Plotly & NetworkX ---
pkg.plot_interactive_scatter_plotly([1, 2, 3], [4, 5, 6])              # needs plotly installed
pkg.plot_matrix_graph([[0, 1], [1, 0]], "graph.png")

# --- Recursive function ---
print(pkg.factorial_recursive(5))                                      # output: 120

# --- Recursive function with memoization ---
print(pkg.fibonacci_memoized(30))                                      # output: 832040

# --- Algorithm Comparison ---
print(pkg.compare_statistic_algorithms([10, 20, 30, 40, 50]))
```