math는 기본 수학 함수를, statistics는 통계 함수를 제공하는 표준 라이브러리입니다. NumPy 없이도 기본적인 수학/통계 연산이 가능합니다.
언제 이 치트시트를 보나?
- 제곱근, 로그, 삼각함수 등이 필요할 때
- 평균, 중앙값, 표준편차 등 기초 통계가 필요할 때
- NumPy 없이 가벼운 수학 연산을 할 때
math 모듈
상수
| |
기본 연산
| |
로그/지수
| |
삼각함수
| |
팩토리얼, GCD, LCM
| |
특수 함수
| |
statistics 모듈
평균
| |
중앙값
| |
최빈값
| |
분산과 표준편차
| |
분위수 (Python 3.8+)
| |
상관계수와 선형회귀 (Python 3.10+)
| |
예제: 기본 통계 분석
| |
자주 하는 실수
1. 부동소수점 비교
| |
2. 정수 나눗셈
| |
한눈에 정리
| 카테고리 | math | statistics |
|---|---|---|
| 기본 연산 | sqrt, pow, ceil, floor | - |
| 삼각함수 | sin, cos, tan, radians | - |
| 로그 | log, log10, exp | - |
| 중심경향 | - | mean, median, mode |
| 분산 | - | stdev, variance |
| 조합 | comb, perm, factorial | - |
![Featured image of post [Python Cheatsheet] 46. math & statistics - 수학/통계 함수](/post/python-cheatsheet/math-statistics-functions-guide-essential-formulas-examples/wordcloud_hu_5b33b9f5df283447.webp)
![[Python Cheatsheet] 44. Database - sqlite3/ORM 기본 패턴](/post/python-cheatsheet/simple-sqlite-database-guide-for-fast-sql-crud-class-methods/wordcloud_hu_2d76ed490f4ec08.webp)
![[Python Cheatsheet] 45. weakref - 약한 참조와 메모리 관리](/post/python-cheatsheet/weakref-memory-leak-circular-reference-garbage-collection-cache/wordcloud_hu_28e728e07b7efa89.webp)
![[Python Cheatsheet] 46. math & statistics - 수학/통계 함수](/post/python-cheatsheet/math-statistics-functions-guide-essential-formulas-examples/wordcloud_hu_849c8affbe8bf7cf.webp)
![[Python Cheatsheet] 47. decimal & fractions - 정밀 수치 연산](/post/python-cheatsheet/decimal-fraction-precision-finance-scientific-guide/wordcloud_hu_a3f3b46f8083983b.webp)
![[Python Cheatsheet] 48. random - 난수 생성과 무작위 선택](/post/python-cheatsheet/random-module-guide-efficient-random-number-generation-examples/wordcloud_hu_7a47f96f9cd69d9f.webp)
![[Hardware] LattePanda Alpha에 Ubuntu 16.04 LTS 설치 가이드](/post/2018-12-06-install-ubuntu-16.04-on-lattepanda/wordcloud_hu_fc536f8de2cbd4bf.webp)
![[Python Cheatsheet] 56. atexit - 프로그램 종료 시 정리](/post/python-cheatsheet/atexit-module-exit-callbacks-cleanup-automation-guide/wordcloud_hu_63c0dcc2b6b75157.webp)
![[Python Cheatsheet] 60. unittest.mock - 모킹과 패칭](/post/python-cheatsheet/effective-mocking-magicmock-patch-unittest-best-practices-guide/wordcloud_hu_9c5e18ebdcb42852.webp)
![[Rust] Comprehensive Rust 무료 강의 정리 및 코스 구조](/post/2022-12-30-comprehensive-rust/wordcloud_hu_d1420ff38434cdb6.webp)
![[Tutorial] Learn Prompting - 프롬프트 엔지니어링 무료 가이드 정리](/post/2022-12-30-learn-prompting/wordcloud_hu_6a9d105de4834753.webp)