mirror of
https://github.com/helblazer811/ManimML.git
synced 2025-06-17 02:58:33 +08:00
Changed directory structure to accomodate examples as apposed to everything being a part of the core library. May need to rethink this in the future. Added some boilerplate for pip packaging to the .gitignore.
This commit is contained in:

committed by
Alec Helbling

parent
4eb5296c9c
commit
3be5c54d26
20
manim_ml/probability_embedding.py
Normal file
20
manim_ml/probability_embedding.py
Normal file
@ -0,0 +1,20 @@
|
||||
from manim import *
|
||||
|
||||
class NeuralNetworkEmbedding(Axes):
|
||||
"""NeuralNetwork embedding object that can show probability distributions"""
|
||||
|
||||
def construct_gaussian_distribution(self, mean, covariance, color=ORANGE, dot_radius=0.05, ellipse_stroke_width=0.3):
|
||||
"""Returns a 2d Gaussian distribution object with given mean and covariance"""
|
||||
# map mean and covariance to frame coordinates
|
||||
mean = self.coords_to_point(*mean)
|
||||
covariance = self.coords_to_point(*covariance)
|
||||
# Make a covariance ellipse centered at mean
|
||||
center_dot = Dot(mean, radius=dot_radius, color=color)
|
||||
ellipse = Ellipse(width=covariance[0], height=covariance[1], color=color, fill_opacity=0.3, stroke_width=ellipse_stroke_width)
|
||||
ellipse.move_to(mean)
|
||||
gaussian_distribution = VGroup(
|
||||
center_dot,
|
||||
ellipse
|
||||
)
|
||||
|
||||
return gaussian_distribution
|
Reference in New Issue
Block a user