Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/afcms/math_algorithms
https://github.com/afcms/math_algorithms
math python
Last synced: 29 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/afcms/math_algorithms
- Owner: AFCMS
- Created: 2022-12-22T20:13:01.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2023-11-21T13:22:24.000Z (about 1 year ago)
- Last Synced: 2024-11-01T09:42:16.006Z (3 months ago)
- Topics: math, python
- Language: Python
- Homepage:
- Size: 403 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Math Algorithms
Some algorithms I made to understand maths better.
| Name | Status | Tests? |
|-------------------------------|--------|--------|
| [Binomial Law](#binomial-law) | Done | ✅ |
| [Matrix](#matrix) | WIP | ✅ |
| Sequences | WIP | ❌ |
| Vectors | TODO | ❌ |## Binomial law
```python
from binomial_law import *# Binomial law of parameters n = 10 and p = 0.2
X = Binomial(10, 0.2)print(f"X -> {X}")
print(f"Expectation of X: {X.expected}")
print(f"Variance of X: {X.variance}")
print(f"Sigma of X: {X.sigma}")
print(f"P(X=8) = {X == 8}")
print(f"P(X>8) = {X > 8}")
print(f"P(X>=8) = {X >= 8}")
print(f"P(X<8) = {X < 8}")
print(f"P(X<=8) = {X <= 8}")
```Also provide function to visualize a law using `matplotlib.pyplot`:
```python
from binomial_law import *X = Binomial(10, 0.2)
show_graph(X)
```![PyCharm Binomial Law](images/binomial_law.png)
# Matrix
```python
from matrix import MatrixA = Matrix([
[1, 2, 3],
[0, 4, -1],
])assert A.size == (2, 3)
assert A.is_square == False
assert A.is_line == False
assert A.is_column == FalseB = Matrix([
[1, 0, 0],
[0, 2, 0],
[0, 0, 0],
])assert B.size == (3, 3)
assert B.is_square == True
assert B.is_line == False
assert B.is_column == Falseassert A * B == Matrix([
[1, 4, 0],
[0, 8, 0]
])assert -A == Matrix([
[-1, -2, -3],
[0, -4, 1],
])I2 = Matrix.identity(2)
O2 = Matrix.null(2)
```