Skip to main content

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)

การใช้งาน

การติดตั้ง(Installation) You can install package from Pypi :

pip install math-stats-raibeena

ตัวอย่าง

import math_stats_raibeena as pkg

# ใช้งานฟังก์ชันเมทริกซ์ (matrix)
u = (1, 2)
v = (3, 4)
m = [[1, 2], [3, 4]]

print(pkg.vector_add(u, v))
print(pkg.dot_product(u, v))
print(pkg.matrix_transpose(m))
print(pkg.matrix_trace(m))
print(pkg.det_2x2(m))


# ใช้งานฟังก์ชันทางสถิติ (statistic)
data_x = [10, 12, 15, 18, 20]
data_y = [5, 8, 10, 14, 18]

print(pkg.mean(data_x))
print(pkg.variance(data_x))
print(pkg.std_dev(data_x))
print(pkg.z_score(15, data_x))
print(pkg.covariance(data_x, data_y))

Improved package

import math

# ==============================================================================
# 1. ส่วนโมดูลแพ็กเกจ (PACKAGE MODULE: math_stats_raibeena)
# ==============================================================================


# ------------------------------------------------------------------------------
# 1.1 String Processing & Data Structures (ส่วนที่เพิ่มใหม่)
# ------------------------------------------------------------------------------
def parse_data_string(data_str: str) -> list[float]:
  """String Processing: แปลงข้อความตัวเลข เช่น '10, 12, 15' เป็น List ของตัวเลข [10.0, 12.0, 15.0]"""
  cleaned = data_str.strip().replace(" ", "")
  if not cleaned:
    return []
  return [float(x) for x in cleaned.split(",")]


def get_data_summary(
    data_x: list[float], tags: set[str] = None
) -> dict[str, str | int | float | list]:
  """Data Structures: ใช้ List, Set และ Dictionary ในการสรุปผลข้อมูลทางสถิติ"""
  tag_set = tags if tags is not None else {"dataset", "math"}  # Set

  summary_dict = {  # Dictionary
      "count": len(data_x),  # List length
      "mean": mean(data_x) if data_x else 0.0,
      "tags": list(tag_set),
  }
  return summary_dict


# ------------------------------------------------------------------------------
# 1.2 ฟังก์ชันเมทริกซ์และเวกเตอร์ 
# ------------------------------------------------------------------------------
def vector_add(
    u: tuple[float, float], v: tuple[float, float]
) -> tuple[float, float]:
  """Data Structure: ใช้ Tuple รับ-ส่งค่าพิกัดเวกเตอร์"""
  return (u[0] + v[0], u[1] + v[1])


def dot_product(u: tuple[float, float], v: tuple[float, float]) -> float:
  return u[0] * v[0] + u[1] * v[1]


def matrix_transpose(m: list[list[float]]) -> list[list[float]]:
  return [[m[0][0], m[1][0]], [m[0][1], m[1][1]]]


def matrix_trace(m: list[list[float]]) -> float:
  return m[0][0] + m[1][1]


def det_2x2(m: list[list[float]]) -> float:
  return m[0][0] * m[1][1] - m[0][1] * m[1][0]


# ------------------------------------------------------------------------------
# 1.3 ฟังก์ชันทางสถิติ 
# ------------------------------------------------------------------------------
def mean(data: list[float]) -> float:
  return sum(data) / len(data)


def variance(data: list[float]) -> float:
  avg = mean(data)
  return sum((x - avg) ** 2 for x in data) / (len(data) - 1)


def std_dev(data: list[float]) -> float:
  return math.sqrt(variance(data))


def z_score(x: float, data: list[float]) -> float:
  return (x - mean(data)) / std_dev(data)


def covariance(data_x: list[float], data_y: list[float]) -> float:
  mean_x = mean(data_x)
  mean_y = mean(data_y)
  n = len(data_x)
  return sum((data_x[i] - mean_x) * (data_y[i] - mean_y) for i in range(n)) / (
      n - 1
  )


# ==============================================================================
# 2. ส่วนการเรียกใช้งาน (EXECUTION & TESTING)
# ==============================================================================
if __name__ == "__main__":
  # --- String Processing (แปลง String เป็น List [float]) ---
  raw_data_x = " 10, 12, 15, 18, 20 "
  raw_data_y = " 5, 8, 10, 14, 18 "

  data_x = parse_data_string(raw_data_x)
  data_y = parse_data_string(raw_data_y)

  # --- ข้อมูลตัวอย่าง Vector & Matrix ---
  u = (1, 2)  # Tuple
  v = (3, 4)  # Tuple
  m = [[1, 2], [3, 4]]  # List

  # --- รันคำสั่งฟังก์ชันเมทริกซ์และเวกเตอร์ ---
  print("=== Vector & Matrix Functions ===")
  print("Vector Add:", vector_add(u, v))
  print("Dot Product:", dot_product(u, v))
  print("Matrix Transpose:", matrix_transpose(m))
  print("Matrix Trace:", matrix_trace(m))
  print("Determinant (2x2):", det_2x2(m))

  # --- รันคำสั่งฟังก์ชันทางสถิติ ---
  print("\n=== Statistics Functions ===")
  print("Mean X:", mean(data_x))
  print("Variance X:", variance(data_x))
  print("Std Dev X:", std_dev(data_x))
  print("Z-Score of 15 in X:", z_score(15, data_x))
  print("Covariance X, Y:", covariance(data_x, data_y))

  # --- รันคำสั่งสรุปผล Data Structures (Set & Dictionary) ---
  print("\n=== Data Structures Summary ===")
  tags = {"statistics", "numerical", "statistics"}  # Set (ตัดค่าซ้ำอัตโนมัติ)
  summary = get_data_summary(data_x, tags)  # คืนค่าเป็น Dictionary
  print("Summary Output:", summary)

Metadata

Release files for math-stats-raibeena 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for math-stats-raibeena 0.1.5
File Size Uploaded Provenance
math_stats_raibeena-0.1.5.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for math-stats-raibeena 0.1.5
File Interpreter ABI Platform
math_stats_raibeena-0.1.5-py3-none-any.whl Python 3 none any Details

Total release size: 10.5 kB

Release files / math_stats_raibeena-0.1.5.tar.gz

Download URL math_stats_raibeena-0.1.5.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
09de586fd7a9176679342a9a000c2c5688671440bb93d578f35b64bbbdadfc4d
BLAKE2b-256 checksum
How to use checksums
e3feaafe7bb75b939843b3776714e2f4a552394a19cae4e5d1833f22185ee563
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / math_stats_raibeena-0.1.5-py3-none-any.whl

Download URL math_stats_raibeena-0.1.5-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3a27662a30e59e77871bea8183919c65d72b800d3b59059242d1def21862c566
BLAKE2b-256 checksum
How to use checksums
432551d8fda1e6b7567fc40b593961c0f75c53e4dca7d2f260044caa2218d473
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Security for math-stats-raibeena 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page