Manim's method 18

Overview

I checked manim's method. I tried using SampleSpaceScene.

Sample code

from manimlib.imports import *

class test(SampleSpaceScene):
	def construct(self):
		sample_space = self.get_sample_space()
		self.add_prior_division()
		self.add(sample_space)
		self.add_conditional_divisions()
		prior_label = sample_space.horizontal_parts.labels[0]
		final_labels = self.final_labels
		hard_to_see = TextMobject("Hard to see")
		hard_to_see.scale(0.7)
		hard_to_see.next_to(prior_label, UP)
		hard_to_see.to_edge(UP)
		hard_to_see.set_color(YELLOW)
		arrow = Arrow(hard_to_see, prior_label)
		self.wait()
		anims = self.get_division_change_animations(sample_space, sample_space.horizontal_parts, 0.001, new_label_kwargs = {"labels" : final_labels})
		self.play(*anims, run_time = 2)
		self.wait()
		self.play(Write(hard_to_see, run_time = 2), ShowCreation(arrow))
		self.wait(2)
	def add_prior_division(self):
		sample_space = self.sample_space
		sample_space.divide_horizontally(0.1)
		initial_labels, final_labels = [VGroup(TexMobject("P(\\text{Disease})", s1), TexMobject("P(\\text{Not disease})", s2),).scale(0.7) for s1, s2 in (("", ""), ("= 0.001", "= 0.999"))]
		sample_space.get_side_braces_and_labels(initial_labels)
		sample_space.add_braces_and_labels()
		self.final_labels = final_labels
	def add_conditional_divisions(self):
		sample_space = self.sample_space
		top_part, bottom_part = sample_space.horizontal_parts
		top_brace = Brace(top_part, UP)
		top_label = TexMobject("P(", "+", "|", "\\text{Disease}", ")", "=", "1")
		top_label.scale(0.7)
		top_label.next_to(top_brace, UP)
		top_label.set_color_by_tex("+", GREEN)
		self.play(GrowFromCenter(top_brace))
		self.play(FadeIn(top_label))
		self.wait()
		bottom_part.divide_vertically(0.95, colors = [BLUE_E, YELLOW_E])
		bottom_label = TexMobject("P(", "+", "|", "\\text{Not disease}", ")", "=", "1")
		bottom_label.scale(0.7)
		bottom_label.set_color_by_tex("+", GREEN)
		braces, labels = bottom_part.get_bottom_braces_and_labels([bottom_label])
		bottom_brace = braces[0]
		self.play(FadeIn(bottom_part.vertical_parts),GrowFromCenter(bottom_brace), )
		self.play(FadeIn(bottom_label))
		self.wait()





Generated video

https://www.youtube.com/watch?v=MeoD6IpM2AM

that's all.

Recommended Posts

Manim's method 13
Manim's method 2
Manim's method 18
Manim's method 17
Manim's method 5
Manim's method 3
Manim's method 15
Manim's method 11
Manim's method 16
Manim's method 20
Manim's method 10
Manim's method 9
Manim's method 6
Manim's method 21
Manim's method 4
Manim's method 8
Manim's method 14
Manim's method 22
Manim's method 19
Manim's method 12
Manim's method part 23
manim's manners
Binary method
Special method
Special method
Understand k-means method
Clustering of clustering method
Dictionary items method
[PyTorch] Installation method
N cross method
Image collection method
Regression analysis method
Gradient method implementation 1
Python-peewee connection method
Class method static method
youtube-dl update method
Monte Carlo method
Mode-Matching Method Simulation_Python
Johnson method (python)
[Python] Semi-Lagrange method