statanim 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- statanim-0.1.0/LICENSE +21 -0
- statanim-0.1.0/PKG-INFO +463 -0
- statanim-0.1.0/README.md +406 -0
- statanim-0.1.0/pyproject.toml +60 -0
- statanim-0.1.0/setup.cfg +4 -0
- statanim-0.1.0/statanim/__init__.py +0 -0
- statanim-0.1.0/statanim/animations/__init__.py +0 -0
- statanim-0.1.0/statanim/animations/clt_demo.py +1852 -0
- statanim-0.1.0/statanim/animations/flip_roll.py +1851 -0
- statanim-0.1.0/statanim/animations/sampling.py +2291 -0
- statanim-0.1.0/statanim/animations/transitions.py +1857 -0
- statanim-0.1.0/statanim/axes/__init__.py +0 -0
- statanim-0.1.0/statanim/axes/axes3d.py +1989 -0
- statanim-0.1.0/statanim/axes/grid3d.py +1127 -0
- statanim-0.1.0/statanim/axes/number_plane3d.py +1526 -0
- statanim-0.1.0/statanim/charts/__init__.py +0 -0
- statanim-0.1.0/statanim/charts/bar_chart3d.py +1572 -0
- statanim-0.1.0/statanim/charts/box_plot3d.py +1977 -0
- statanim-0.1.0/statanim/charts/heat_map3d.py +1639 -0
- statanim-0.1.0/statanim/charts/histogram3d.py +1019 -0
- statanim-0.1.0/statanim/charts/line_plot3d.py +1891 -0
- statanim-0.1.0/statanim/charts/scatter_plot3d.py +1469 -0
- statanim-0.1.0/statanim/charts/violin_plot3d.py +1567 -0
- statanim-0.1.0/statanim/core/__init__.py +0 -0
- statanim-0.1.0/statanim/core/base.py +1585 -0
- statanim-0.1.0/statanim/core/colors.py +1373 -0
- statanim-0.1.0/statanim/core/math_utils.py +2081 -0
- statanim-0.1.0/statanim/core/tex_utils.py +2111 -0
- statanim-0.1.0/statanim/distributions/__init__.py +0 -0
- statanim-0.1.0/statanim/distributions/base_dist.py +1936 -0
- statanim-0.1.0/statanim/distributions/cdf_viz.py +1773 -0
- statanim-0.1.0/statanim/distributions/continuous_dists.py +1769 -0
- statanim-0.1.0/statanim/distributions/discrete_dists.py +1734 -0
- statanim-0.1.0/statanim/distributions/normal3d.py +1877 -0
- statanim-0.1.0/statanim/distributions/pdf_viz.py +2247 -0
- statanim-0.1.0/statanim/distributions/pmf_viz.py +1936 -0
- statanim-0.1.0/statanim/inference/__init__.py +0 -0
- statanim-0.1.0/statanim/inference/confidence_interval.py +1693 -0
- statanim-0.1.0/statanim/inference/error_types.py +1825 -0
- statanim-0.1.0/statanim/inference/hypothesis.py +1821 -0
- statanim-0.1.0/statanim/inference/sampling_dist.py +1933 -0
- statanim-0.1.0/statanim/probability/__init__.py +0 -0
- statanim-0.1.0/statanim/probability/bayes.py +1682 -0
- statanim-0.1.0/statanim/probability/prob_tree.py +1478 -0
- statanim-0.1.0/statanim/probability/sample_space.py +1642 -0
- statanim-0.1.0/statanim/probability/venn3d.py +1857 -0
- statanim-0.1.0/statanim/props/__init__.py +0 -0
- statanim-0.1.0/statanim/props/card.py +2259 -0
- statanim-0.1.0/statanim/props/coin.py +1011 -0
- statanim-0.1.0/statanim/props/die.py +1391 -0
- statanim-0.1.0/statanim/props/spinner.py +1591 -0
- statanim-0.1.0/statanim/props/urn.py +1531 -0
- statanim-0.1.0/statanim/regression/__init__.py +0 -0
- statanim-0.1.0/statanim/regression/correlation.py +2805 -0
- statanim-0.1.0/statanim/regression/regression_plane.py +2286 -0
- statanim-0.1.0/statanim/regression/residuals.py +2599 -0
- statanim-0.1.0/statanim/scenes/__init__.py +0 -0
- statanim-0.1.0/statanim/scenes/demo_bayes.py +2056 -0
- statanim-0.1.0/statanim/scenes/demo_clt.py +1756 -0
- statanim-0.1.0/statanim/scenes/demo_distributions.py +1905 -0
- statanim-0.1.0/statanim/scenes/demo_hypothesis.py +1791 -0
- statanim-0.1.0/statanim/ui/__init__.py +0 -0
- statanim-0.1.0/statanim/ui/labels.py +1844 -0
- statanim-0.1.0/statanim/ui/panels.py +1937 -0
- statanim-0.1.0/statanim/ui/table3d.py +1745 -0
- statanim-0.1.0/statanim/ui/ticker.py +2007 -0
- statanim-0.1.0/statanim.egg-info/PKG-INFO +463 -0
- statanim-0.1.0/statanim.egg-info/SOURCES.txt +69 -0
- statanim-0.1.0/statanim.egg-info/dependency_links.txt +1 -0
- statanim-0.1.0/statanim.egg-info/requires.txt +9 -0
- statanim-0.1.0/statanim.egg-info/top_level.txt +1 -0
statanim-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Rishabh Bhartiya
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
statanim-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,463 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: statanim
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Manim extension for animated statistical visualisations — distributions, regression, probability, inference and more.
|
|
5
|
+
Author-email: Rishabh Bhartiya <rishabh.bhartiya.in@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 Rishabh Bhartiya
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/rishabhbhartiya/statanim
|
|
29
|
+
Project-URL: Documentation, https://github.com/rishabhbhartiya/statanim/blob/main/API_REFERENCE.md
|
|
30
|
+
Project-URL: Bug Tracker, https://github.com/rishabhbhartiya/statanim/issues
|
|
31
|
+
Project-URL: Source Code, https://github.com/rishabhbhartiya/statanim
|
|
32
|
+
Keywords: manim,statistics,animation,data-science,probability,regression,distribution,education,visualisation,math
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Education
|
|
35
|
+
Classifier: Intended Audience :: Science/Research
|
|
36
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
37
|
+
Classifier: Topic :: Scientific/Engineering :: Visualization
|
|
38
|
+
Classifier: Topic :: Education
|
|
39
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
40
|
+
Classifier: Programming Language :: Python :: 3
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
42
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
43
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
44
|
+
Classifier: Operating System :: OS Independent
|
|
45
|
+
Requires-Python: >=3.10
|
|
46
|
+
Description-Content-Type: text/markdown
|
|
47
|
+
License-File: LICENSE
|
|
48
|
+
Requires-Dist: manim>=0.18.0
|
|
49
|
+
Requires-Dist: numpy>=1.24
|
|
50
|
+
Requires-Dist: scipy>=1.10
|
|
51
|
+
Provides-Extra: dev
|
|
52
|
+
Requires-Dist: build; extra == "dev"
|
|
53
|
+
Requires-Dist: twine; extra == "dev"
|
|
54
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
55
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
56
|
+
Dynamic: license-file
|
|
57
|
+
|
|
58
|
+
<div align="center">
|
|
59
|
+
|
|
60
|
+
<img src="./banner.svg" alt="STATANIM — Statistical Animation for Manim" width="680"/>
|
|
61
|
+
|
|
62
|
+
<br/>
|
|
63
|
+
|
|
64
|
+
[](https://pypi.org/project/statanim/)
|
|
65
|
+
[](https://www.python.org/downloads/)
|
|
66
|
+
[](https://www.manim.community/)
|
|
67
|
+
[](./LICENSE)
|
|
68
|
+
|
|
69
|
+
**A Manim extension for animated statistical visualisations.**
|
|
70
|
+
Distributions, inference, regression, probability theory, and physical props —
|
|
71
|
+
all built on [Manim Community](https://www.manim.community/).
|
|
72
|
+
|
|
73
|
+
</div>
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
## Overview
|
|
78
|
+
|
|
79
|
+
`statanim` adds domain-specific tools to Manim that standard Manim does not provide:
|
|
80
|
+
statistically-aware objects that understand distributions, parameters, and sampling;
|
|
81
|
+
preset animation sequences for common demonstrations; 3D charts with correct depth
|
|
82
|
+
perception; and physical probability props (dice, coins, cards, urns) that carry
|
|
83
|
+
their own probability logic.
|
|
84
|
+
|
|
85
|
+
The library is structured around the same workflow as Manim: you create objects,
|
|
86
|
+
add them to a scene, and call `self.play()`. Everything that is specific to statistics
|
|
87
|
+
lives in `statanim`. Everything else remains standard Manim.
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Demo
|
|
92
|
+
|
|
93
|
+
| Sample Space | Classical Probability |
|
|
94
|
+
|:---:|:---:|
|
|
95
|
+
|  |  |
|
|
96
|
+
|
|
97
|
+
| Conditional Probability | Hypergeometric Distribution |
|
|
98
|
+
|:---:|:---:|
|
|
99
|
+
|  |  |
|
|
100
|
+
|
|
101
|
+
<div align="center">
|
|
102
|
+
|
|
103
|
+
**Birthday Paradox**
|
|
104
|
+
|
|
105
|
+

|
|
106
|
+
|
|
107
|
+
</div>
|
|
108
|
+
|
|
109
|
+
---
|
|
110
|
+
|
|
111
|
+
## Installation
|
|
112
|
+
|
|
113
|
+
**Prerequisites**
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
pip install manim
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
LaTeX is required for formula rendering:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
# macOS
|
|
123
|
+
brew install mactex-no-gui
|
|
124
|
+
|
|
125
|
+
# Ubuntu / Debian
|
|
126
|
+
sudo apt-get install texlive-full
|
|
127
|
+
|
|
128
|
+
# Windows: install MiKTeX from https://miktex.org/
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Install statanim**
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
pip install statanim
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
**Install from source**
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
git clone https://github.com/rishabhbhartiya/statanim.git
|
|
141
|
+
cd statanim
|
|
142
|
+
pip install -e .
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
**Verify**
|
|
146
|
+
|
|
147
|
+
```python
|
|
148
|
+
from manim import *
|
|
149
|
+
from statanim.props.card import Card3D
|
|
150
|
+
from statanim.distributions.normal3d import NormalCurve3D
|
|
151
|
+
from statanim.core.colors import DARK_THEME
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Quick Start
|
|
157
|
+
|
|
158
|
+
### Normal distribution with shaded region
|
|
159
|
+
|
|
160
|
+
```python
|
|
161
|
+
from manim import *
|
|
162
|
+
from statanim.distributions.normal3d import NormalCurve3D
|
|
163
|
+
|
|
164
|
+
class NormalDemo(Scene):
|
|
165
|
+
def construct(self):
|
|
166
|
+
axes = Axes(x_range=[-4, 4, 1], y_range=[0, 0.45, 0.1],
|
|
167
|
+
x_length=8, y_length=4)
|
|
168
|
+
curve = NormalCurve3D(mu=0, sigma=1, axes=axes)
|
|
169
|
+
|
|
170
|
+
self.play(Create(axes))
|
|
171
|
+
self.play(Create(curve))
|
|
172
|
+
self.play(curve.shade_region(x_min=-1, x_max=1))
|
|
173
|
+
self.wait(2)
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
### Central Limit Theorem
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from manim import *
|
|
180
|
+
from statanim.animations.clt_demo import CLTDemo
|
|
181
|
+
|
|
182
|
+
class CLTScene(ThreeDScene):
|
|
183
|
+
def construct(self):
|
|
184
|
+
self.set_camera_orientation(phi=70*DEGREES, theta=-45*DEGREES)
|
|
185
|
+
demo = CLTDemo(source="uniform", params={"a": 0, "b": 1}, n_samples=500)
|
|
186
|
+
demo.run(self)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Probability with playing cards
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
from manim import *
|
|
193
|
+
from statanim.props.card import Deck3D, CardFacing, standard_deck
|
|
194
|
+
|
|
195
|
+
class CardDraw(Scene):
|
|
196
|
+
def construct(self):
|
|
197
|
+
deck = Deck3D(cards=standard_deck(shuffle=True, seed=0),
|
|
198
|
+
initial_facing=CardFacing.FACE_DOWN)
|
|
199
|
+
deck.move_to(LEFT * 3)
|
|
200
|
+
self.play(FadeIn(deck))
|
|
201
|
+
self.play(deck.deal_one(target=RIGHT * 2, flip=True))
|
|
202
|
+
self.wait(2)
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Module Structure
|
|
208
|
+
|
|
209
|
+
```
|
|
210
|
+
statanim/
|
|
211
|
+
├── animations/
|
|
212
|
+
│ ├── clt_demo.py CLTDemo, PopulationDistribution3D, SampleMeanHistogram3D
|
|
213
|
+
│ ├── flip_roll.py Coin flip and die roll animations
|
|
214
|
+
│ ├── sampling.py SimpleRandomSampling3D, StratifiedSampling3D,
|
|
215
|
+
│ │ ClusterSampling3D, BootstrapSampling3D
|
|
216
|
+
│ └── transitions.py DistMorph3D, HistMorph3D, CDFBuild3D,
|
|
217
|
+
│ ParameterSweep3D, ScatterToRegression3D
|
|
218
|
+
│
|
|
219
|
+
├── axes/
|
|
220
|
+
│ ├── axes3d.py Enhanced ThreeDAxes with statistical tick formatting
|
|
221
|
+
│ ├── grid3d.py FullGrid3D, statistical grid overlays
|
|
222
|
+
│ └── number_plane3d.py 3D number planes for bivariate data
|
|
223
|
+
│
|
|
224
|
+
├── charts/
|
|
225
|
+
│ ├── bar_chart3d.py BarChart3D, grouped and stacked variants
|
|
226
|
+
│ ├── box_plot3d.py BoxPlot3D with whiskers and outlier markers
|
|
227
|
+
│ ├── heat_map3d.py HeatMap3D for correlation and confusion matrices
|
|
228
|
+
│ ├── histogram3d.py Histogram3D with configurable binning
|
|
229
|
+
│ ├── line_plot3d.py LinePlot3D, MultiLine3D, CDFLine3D, ParametricCurve3D
|
|
230
|
+
│ ├── scatter_plot3d.py ScatterPlot3D with regression overlay
|
|
231
|
+
│ └── violin_plot3d.py ViolinPlot3D for distribution shape comparison
|
|
232
|
+
│
|
|
233
|
+
├── core/
|
|
234
|
+
│ ├── base.py StatsObject3D base class
|
|
235
|
+
│ ├── colors.py StatColor, ColorFamily, StatsTheme, 6 built-in themes
|
|
236
|
+
│ ├── math_utils.py PDF, CDF, PMF computation helpers
|
|
237
|
+
│ └── tex_utils.py TexFormula, 50+ formula builders, formula registry
|
|
238
|
+
│
|
|
239
|
+
├── distributions/
|
|
240
|
+
│ ├── base_dist.py BaseDistribution3D
|
|
241
|
+
│ ├── continuous_dists.py Exponential, Gamma, Beta, Chi-squared, Student-t, F
|
|
242
|
+
│ ├── discrete_dists.py Binomial, Poisson, Geometric, Hypergeometric
|
|
243
|
+
│ ├── normal3d.py NormalCurve3D, BivariateNormal3D
|
|
244
|
+
│ ├── pdf_viz.py PDFVisualizer3D with shaded regions
|
|
245
|
+
│ ├── pmf_viz.py PMFVisualizer3D
|
|
246
|
+
│ └── cdf_viz.py CDFVisualizer3D
|
|
247
|
+
│
|
|
248
|
+
├── inference/
|
|
249
|
+
│ ├── hypothesis.py HypothesisRegion3D, rejection zones
|
|
250
|
+
│ ├── confidence_interval.py ConfidenceInterval3D
|
|
251
|
+
│ ├── sampling_dist.py SamplingDistribution3D, CLT demonstration
|
|
252
|
+
│ └── error_types.py Type I / Type II error visualisation
|
|
253
|
+
│
|
|
254
|
+
├── probability/
|
|
255
|
+
│ ├── bayes.py BayesBox3D, prior/posterior update
|
|
256
|
+
│ ├── prob_tree.py ProbabilityTree3D
|
|
257
|
+
│ ├── sample_space.py SampleSpace3D, EventRegion3D
|
|
258
|
+
│ └── venn3d.py VennDiagram3D (2-set and 3-set)
|
|
259
|
+
│
|
|
260
|
+
├── props/
|
|
261
|
+
│ ├── card.py Card3D, Deck3D, CardFace, deal/shuffle/flip animations
|
|
262
|
+
│ ├── coin.py Coin3D with flip animation
|
|
263
|
+
│ ├── die.py Die3D (D4, D6, D8, D12, D20) with roll animation
|
|
264
|
+
│ ├── spinner.py Spinner3D with sector probabilities
|
|
265
|
+
│ └── urn.py Urn3D and Ball3D for sampling models
|
|
266
|
+
│
|
|
267
|
+
├── regression/
|
|
268
|
+
│ ├── correlation.py pearson, spearman, kendall, OLS fit,
|
|
269
|
+
│ │ CorrelationEllipse3D, CorrelationMatrix3D
|
|
270
|
+
│ ├── regression_plane.py RegressionPlane3D, ScatterCloud3D,
|
|
271
|
+
│ │ PlaneResiduals3D, CIShell3D, PIShell3D
|
|
272
|
+
│ └── residuals.py ResidualVsFittedPlot, QQPlot3D, ScaleLocationPlot,
|
|
273
|
+
│ InfluencePlot3D, DiagnosticPanel
|
|
274
|
+
│
|
|
275
|
+
├── scenes/
|
|
276
|
+
│ ├── demo_bayes.py Bayesian inference demonstration
|
|
277
|
+
│ ├── demo_clt.py Central Limit Theorem demonstration
|
|
278
|
+
│ ├── demo_distributions.py Distribution showcase
|
|
279
|
+
│ └── demo_hypothesis.py Hypothesis testing demonstration
|
|
280
|
+
│
|
|
281
|
+
└── ui/
|
|
282
|
+
├── labels.py StatLabel3D, AnnotationArrow3D
|
|
283
|
+
├── panels.py FormulaPanel3D, LegendPanel3D
|
|
284
|
+
├── table3d.py DataTable3D floating data grid
|
|
285
|
+
└── ticker.py Ticker3D, PValueTicker3D, TickerGroup3D
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Key Classes
|
|
291
|
+
|
|
292
|
+
### Distributions
|
|
293
|
+
|
|
294
|
+
| Class | Module | Parameters |
|
|
295
|
+
|---|---|---|
|
|
296
|
+
| `NormalCurve3D` | `distributions.normal3d` | `mu`, `sigma`, `axes`, `color` |
|
|
297
|
+
| `BivariateNormal3D` | `distributions.normal3d` | `mu1`, `mu2`, `sigma1`, `sigma2`, `rho` |
|
|
298
|
+
| `PDFVisualizer3D` | `distributions.pdf_viz` | `pdf_func`, `x_range`, `axes` |
|
|
299
|
+
| `PMFVisualizer3D` | `distributions.pmf_viz` | `pmf_dict`, `axes` |
|
|
300
|
+
| `CDFVisualizer3D` | `distributions.cdf_viz` | `cdf_func`, `x_range`, `axes` |
|
|
301
|
+
|
|
302
|
+
### Props
|
|
303
|
+
|
|
304
|
+
| Class | Module | Key animations |
|
|
305
|
+
|---|---|---|
|
|
306
|
+
| `Card3D` | `props.card` | `flip()`, `deal_anim()`, `reveal_anim()` |
|
|
307
|
+
| `Deck3D` | `props.card` | `deal_one()`, `deal_n()`, `shuffle_anim()`, `fan_out()` |
|
|
308
|
+
| `Coin3D` | `props.coin` | `flip_anim()` |
|
|
309
|
+
| `Die3D` | `props.die` | `roll_anim()` |
|
|
310
|
+
| `Urn3D` | `props.urn` | `draw_anim()`, `replace_anim()` |
|
|
311
|
+
|
|
312
|
+
### Regression
|
|
313
|
+
|
|
314
|
+
| Class | Module | Description |
|
|
315
|
+
|---|---|---|
|
|
316
|
+
| `RegressionPlane3D` | `regression.regression_plane` | Fitted plane for two-predictor OLS |
|
|
317
|
+
| `ScatterCloud3D` | `regression.regression_plane` | 3D scatter coloured by residual or leverage |
|
|
318
|
+
| `PlaneResiduals3D` | `regression.regression_plane` | Vertical residual lines to the fitted plane |
|
|
319
|
+
| `CIShell3D` | `regression.regression_plane` | 95% confidence surface around the plane |
|
|
320
|
+
| `DiagnosticPanel` | `regression.residuals` | 2×2 grid: residual plot, Q-Q, scale-location, influence |
|
|
321
|
+
|
|
322
|
+
### UI
|
|
323
|
+
|
|
324
|
+
| Class | Module | Description |
|
|
325
|
+
|---|---|---|
|
|
326
|
+
| `Ticker3D` | `ui.ticker` | Animated statistical value badge with `count_to()`, `odometer_to()` |
|
|
327
|
+
| `PValueTicker3D` | `ui.ticker` | P-value ticker with significance stars and threshold colouring |
|
|
328
|
+
| `TickerGroup3D` | `ui.ticker` | Dashboard of multiple tickers in row / column / grid layout |
|
|
329
|
+
| `FormulaPanel3D` | `ui.panels` | Floating LaTeX formula overlay panel |
|
|
330
|
+
| `DataTable3D` | `ui.table3d` | Floating data table in 3D space |
|
|
331
|
+
|
|
332
|
+
### Color system
|
|
333
|
+
|
|
334
|
+
```python
|
|
335
|
+
from statanim.core.colors import DARK_THEME, LIGHT_THEME, PAPER_THEME
|
|
336
|
+
from statanim.core.colors import NORMAL_FAMILY, REGRESSION_FAMILY, INFERENCE_FAMILY
|
|
337
|
+
|
|
338
|
+
# Apply a theme to a scene
|
|
339
|
+
DARK_THEME.apply(self)
|
|
340
|
+
|
|
341
|
+
# Use a family colour
|
|
342
|
+
curve.set_color(ManimColor(NORMAL_FAMILY.base.hex))
|
|
343
|
+
|
|
344
|
+
# Diverging colormap for a heatmap
|
|
345
|
+
from statanim.core.colors import diverging_map, PURPLE_700, CORAL_700
|
|
346
|
+
cmap = diverging_map(PURPLE_700, CORAL_700, n=256)
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
---
|
|
350
|
+
|
|
351
|
+
## Camera Orientation Reference
|
|
352
|
+
|
|
353
|
+
All `ThreeDScene` subclasses need an explicit camera orientation at the top of
|
|
354
|
+
`construct()`. Without it everything appears flat on the floor.
|
|
355
|
+
|
|
356
|
+
```python
|
|
357
|
+
def construct(self):
|
|
358
|
+
self.set_camera_orientation(phi=70*DEGREES, theta=-45*DEGREES)
|
|
359
|
+
# ... rest of scene
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
Recommended values by scene type:
|
|
363
|
+
|
|
364
|
+
| Scene type | phi | theta |
|
|
365
|
+
|---|---|---|
|
|
366
|
+
| 3D bar chart | 65° | -55° |
|
|
367
|
+
| Regression plane | 70° | -45° |
|
|
368
|
+
| Scatter cloud | 70° | -60° |
|
|
369
|
+
| Card grid (table-top) | 60° | -45° |
|
|
370
|
+
| Bivariate normal surface | 68° | -45° |
|
|
371
|
+
|
|
372
|
+
Use `Scene` (not `ThreeDScene`) for all 2D content: PDF curves, PMF bars,
|
|
373
|
+
Venn diagrams, histograms, box plots, probability trees, and hypothesis test plots.
|
|
374
|
+
|
|
375
|
+
---
|
|
376
|
+
|
|
377
|
+
## Examples
|
|
378
|
+
|
|
379
|
+
The `examples/` directory contains six working scenes:
|
|
380
|
+
|
|
381
|
+
| File | Scene | Concepts |
|
|
382
|
+
|---|---|---|
|
|
383
|
+
| `examples/card_probability_scene.py` | `CardProbabilityScene` | Sample space, classical probability |
|
|
384
|
+
| `examples/classical_probability.py` | `ClassicalProbabilityScene` | P(A), P(B), P(A∩B), addition rule |
|
|
385
|
+
| `examples/conditional_probability.py` | `ConditionalProbabilityScene` | P(A\|B), independence |
|
|
386
|
+
| `examples/hypergeometricscene.py` | `HypergeometricScene` | Hypergeometric PMF, sampling without replacement |
|
|
387
|
+
| `examples/birthdayparadox_scene.py` | `BirthdayParadoxScene` | Birthday problem, collision probability |
|
|
388
|
+
| `examples/card_probability.py` | `CardProbabilityScene` | Full card probability demonstration |
|
|
389
|
+
|
|
390
|
+
Run any example:
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
manim -pql examples/classical_probability.py ClassicalProbabilityScene
|
|
394
|
+
manim -pqh examples/classical_probability.py ClassicalProbabilityScene # high quality
|
|
395
|
+
```
|
|
396
|
+
|
|
397
|
+
---
|
|
398
|
+
|
|
399
|
+
## API Reference
|
|
400
|
+
|
|
401
|
+
Full class, function, and parameter documentation is in
|
|
402
|
+
[API_REFERENCE.md](./API_REFERENCE.md).
|
|
403
|
+
|
|
404
|
+
The reference covers all 57 files across 13 modules.
|
|
405
|
+
[REFERENCE.md](./REFERENCE.md) contains narrative documentation
|
|
406
|
+
for each module.
|
|
407
|
+
|
|
408
|
+
To regenerate the reference files after making changes:
|
|
409
|
+
|
|
410
|
+
```bash
|
|
411
|
+
python reference.py
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
---
|
|
415
|
+
|
|
416
|
+
## Requirements
|
|
417
|
+
|
|
418
|
+
| Package | Minimum version |
|
|
419
|
+
|---|---|
|
|
420
|
+
| Python | 3.10 |
|
|
421
|
+
| manim | 0.18.0 |
|
|
422
|
+
| numpy | 1.24 |
|
|
423
|
+
| scipy | 1.10 |
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Development Setup
|
|
428
|
+
|
|
429
|
+
```bash
|
|
430
|
+
git clone https://github.com/rishabhbhartiya/statanim.git
|
|
431
|
+
cd statanim
|
|
432
|
+
python -m venv .venv
|
|
433
|
+
source .venv/bin/activate # Windows: .venv\Scripts\activate
|
|
434
|
+
pip install -e ".[dev]"
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
---
|
|
438
|
+
|
|
439
|
+
## Contributing
|
|
440
|
+
|
|
441
|
+
Issues and pull requests are welcome at
|
|
442
|
+
[github.com/rishabhbhartiya/statanim](https://github.com/rishabhbhartiya/statanim).
|
|
443
|
+
|
|
444
|
+
When adding a new distribution, inherit from `BaseDistribution3D`,
|
|
445
|
+
implement `pdf`/`pmf`, `cdf`, `mean`, `variance`, and add a scene in
|
|
446
|
+
`scenes/demo_distributions.py`.
|
|
447
|
+
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
## Acknowledgements
|
|
451
|
+
|
|
452
|
+
Built on [Manim Community](https://www.manim.community/).
|
|
453
|
+
Statistical algorithms from [SciPy](https://scipy.org/) and
|
|
454
|
+
[NumPy](https://numpy.org/).
|
|
455
|
+
Inspired by the mathematical animation work of 3Blue1Brown.
|
|
456
|
+
|
|
457
|
+
---
|
|
458
|
+
|
|
459
|
+
## License
|
|
460
|
+
|
|
461
|
+
MIT License. See [LICENSE](./LICENSE) for details.
|
|
462
|
+
|
|
463
|
+
**Author:** Rishabh Bhartiya — [rishabh.bhartiya.in@gmail.com](mailto:rishabh.bhartiya.in@gmail.com)
|