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.6

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.6
File Size Uploaded Provenance
math_stats_raibeena-0.1.6.tar.gz 5.0 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 10.5 kB

Release files / math_stats_raibeena-0.1.6.tar.gz

Download URL math_stats_raibeena-0.1.6.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
d657cf461b52a11fbc7b397757abcf1438967c90d868fe600a3cae7c5bb56152
BLAKE2b-256 checksum
How to use checksums
5af4d03c5249d9521f17cde377bd0f8ae046a80d581e0908bd4e9f00ae31bcd7
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.6-py3-none-any.whl

Download URL math_stats_raibeena-0.1.6-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b75970a1656c22104e7abd606dcc06b766bfaf7abf9cad9acd80c00987d508a
BLAKE2b-256 checksum
How to use checksums
89956c1d1166acd917b8f659562a94ad3297d18917148f73b1aad8ce0304ab91
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.6

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