Created
February 16, 2023 10:28
-
-
Save fbkarsdorp/dacd7fed8beb7fc3821eef592f1ddb75 to your computer and use it in GitHub Desktop.
Manim video showing the overestimating effect of applying the wrong unseen species estimator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
def sailor_legend(color, text): | |
text = Text(text, color=BLACK, font_size=24) | |
sailor = ImageMobject(f"sailor-{color}.png").scale(0.15) | |
return Group(sailor, text).arrange(RIGHT) | |
rng = np.random.RandomState(2029) #1989 #2019 | |
class ShipScene(SpaceScene): | |
def construct(self): | |
bg = FullScreenRectangle() | |
bg.set_fill("#FFFFFF", 1) | |
self.add(bg) | |
observed = int(460 / 25) | |
x_pos = rng.normal(0, 1, observed) | |
y_pos = rng.normal(0, 0.4, observed) | |
sailors = Group(*[ImageMobject( | |
f"sailor-green.png").scale(0.18).move_to( | |
np.array([x_pos[i], y_pos[i], 0])) for i in range(observed)]) | |
grey_sailor = sailor_legend("grey", "25k each") | |
green_sailor = sailor_legend("green", "460k seen") | |
blue_sailor = sailor_legend("blue", "255k unseen") | |
red_sailor = sailor_legend("red", "2.3M overestimated") | |
legend = Group( | |
grey_sailor, green_sailor, blue_sailor, red_sailor | |
).arrange(DOWN, aligned_edge=LEFT, buff=0.1).shift(UP * 2.5 + LEFT * 5.3) | |
ground = Line([-6.7, -3.9, 0], [6.7, -3.9, 0], color=WHITE) | |
wall1 = Line([-3.7, -3.9, 0], [-4.1, -1.5, 0], color=WHITE) | |
wall2 = Line([2.1, -3.9, 0], [3.4, -1.7, 0], color=WHITE) | |
wall3 = Line([-6.7, -3.9, 0], [-6.7, 3.9, 0], color=WHITE) | |
wall4 = Line([6.7, -3.9, 0], [6.7, 3.9, 0], color=WHITE) | |
walls = VGroup(ground, wall1, wall2)#, wall3, wall4) | |
self.add(walls) | |
ship = ImageMobject("boat2.png").shift(DOWN) | |
self.add(ship) | |
self.play( | |
FadeIn(sailors), | |
FadeIn(grey_sailor), | |
FadeIn(green_sailor), | |
) | |
self.make_static_body(walls, elasticity=0.8, friction=0.8) | |
self.make_rigid_body(*sailors, elasticity=0.8, friction=0.8) # Mobjects will move with gravity | |
# Mobjects will stay in place | |
self.wait(5) | |
estimated = int((716 - 460) / 25) | |
x_pos = rng.normal(-0.5, 1.1, estimated) | |
y_pos = rng.normal(0, 0.4, estimated) | |
est_sailors = Group(*[ImageMobject( | |
f"sailor-blue.png").scale(0.18).move_to( | |
np.array([x_pos[i], 1 + y_pos[i], 0])) for i in range(estimated)]) | |
self.play( | |
FadeIn(est_sailors), | |
FadeIn(blue_sailor), | |
run_time=0.5 | |
) | |
self.make_rigid_body(*est_sailors, elasticity=0.8, friction=0.8) # Mobjects will move with gravity | |
# Mobjects will stay in place | |
self.wait(5) | |
overestimated = int((2300 - 710) / 25) | |
x_pos = rng.normal(0, 1.2, overestimated) | |
y_pos = rng.normal(0, 0.4, overestimated) | |
overest_sailors = Group(*[ImageMobject( | |
f"sailor-red.png").scale(0.18).move_to( | |
np.array([x_pos[i], 2 + y_pos[i], 0])) for i in range(overestimated)]) | |
self.play( | |
FadeIn(overest_sailors), | |
FadeIn(red_sailor), | |
run_time=0.5 | |
) | |
self.make_rigid_body(*overest_sailors) # Mobjects will move with gravity | |
# Mobjects will stay in place | |
self.wait(10) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment