Pure Python math library: NumPy-like API on pure Python lists (NumPy-free)
This package uses only Python standard library modules:
| Module | Purpose |
|---|---|
math |
Basic math functions |
random |
Random number generation |
statistics |
Statistical functions |
cmath |
Complex math (FFT) |
builtins |
Built-in functions |
typing |
Type hints |
collections |
Data structures |
Uses Python's stdlib random module with reproducible seeding:
import random
rng = random.Random(seed) # Reproducible RNG
rng.random() # Generate random float
rng.shuffle(list) # Shuffle in place- Array Operations: array, zeros, ones, eye, transpose, dot, matmul
- Math: exp, log, sqrt, clip, norm, l2_normalize
- Statistics: mean, var, std, median, percentile, correlation
- Distance/Similarity: cosine, euclidean, manhattan, hamming
- ML Algorithms: logistic regression, SVM, k-means, PCA, GMM, Naive Bayes
- Losses: MSE, cross-entropy, focal, hinge, KL divergence, triplet
- Metrics: precision, recall, F1, ROC-AUC, confusion matrix
- Signal Processing: FFT, wavelets, STL decomposition, filtering
- Network Analysis: centrality, PageRank, community detection
- Trading: technical indicators, strategies, risk management
pip install -e packages/tidyllm-puremathimport tlm
# Array operations
x = tlm.array([[1, 2], [3, 4]])
y = tlm.transpose(x)
z = tlm.matmul(x, y)
# ML algorithms
model = tlm.logreg_fit(X_train, y_train)
predictions = tlm.logreg_predict(X_test, model)
# Metrics
acc = tlm.accuracy(y_true, y_pred)
f1 = tlm.f1_score(y_true, y_pred)CC BY 4.0