File:Scaling exponential distribution.webm

From Wikimedia Commons, the free media repository
Jump to navigation Jump to search

Original file (WebM audio/video file, VP9, length 5.0 s, 1,920 × 1,080 pixels, 1.4 Mbps overall, file size: 853 KB)

Captions

Captions

Add a one-line explanation of what this file represents

Summary

[edit]
Description
English: PDF of exponential random variable that is being scaled by a constant factor
Беларуская: Залежнасць графіка шчыльнасці паказнікава размеркаванай выпадковай велічыні, якую дамнажаюць на канстанту, ад значэння гэтай канстанты
Date
Source Own work
Author A potato hater
WEBM development
InfoField
 
This WEBM graphic was created with Python.

Python Script

[edit]

Created with manim Python package

from manim import *
import numpy as np


def color_to_numpy(color):
    color = color.lstrip("#")
    return np.array([int(color[i : i + 2], 16) for i in (0, 2, 4)])


def numpy_to_color(arr):
    r, g, b = arr.round().astype(int)
    return "#%02x%02x%02x" % (r, g, b)


class ScaleExpDistribution(Scene):
    def get_rectangle_corners(self, bottom_left, top_right):
        return [
            (top_right[0], top_right[1]),
            (bottom_left[0], top_right[1]),
            (bottom_left[0], bottom_left[1]),
            (top_right[0], bottom_left[1]),
        ]

    def construct(self):
        FONT_SIZE = 96
        START_VALUE = 1
        END_VALUE = 2
        START_COLOR = color_to_numpy(YELLOW)
        END_COLOR = color_to_numpy(RED)

        t = ValueTracker(START_VALUE)

        axes = Axes(x_range=(0, 3.2, 0.5), y_range=(0, 1.1, 0.1))
        axes.add_coordinates()
        x_label = axes.get_x_axis_label("x")
        x_label.shift(0.7 * DOWN)
        y_label = axes.get_y_axis_label("f_\eta (x)")
        y_label.shift(0.8 * LEFT)

        def get_graph():
            t_value = t.get_value()
            alpha = (t_value - START_VALUE) / (END_VALUE - START_VALUE)
            color = numpy_to_color(START_COLOR + (alpha * (END_COLOR - START_COLOR)))
            xi_text = MathTex(r"\xi \sim Exp(1)", font_size=FONT_SIZE)

            number = DecimalNumber().set_color(color).set_value(t_value)
            number.font_size = FONT_SIZE
            eta_text = VGroup(
                MathTex(r"\eta = ", font_size=FONT_SIZE),
                number,
                MathTex(r"\xi", font_size=FONT_SIZE),
            ).arrange()

            dist_text = VGroup(xi_text, eta_text).arrange(DOWN)
            dist_text.to_corner(UP + RIGHT)

            rate = 1 / t_value
            exp_pdf = lambda x: rate * np.exp(-rate * x)
            graph = axes.plot(exp_pdf, x_range=(0, 3.1), color=color)

            starting_points = [0.25, 0.5, 0.75, 1, 1.25, 1.5]
            polygons = []
            for starting_point in starting_points:
                x_value = starting_point * (t_value / START_VALUE)
                polygon = Polygon(
                    *[
                        axes.c2p(*i)
                        for i in self.get_rectangle_corners(
                            (0, 0), (x_value, exp_pdf(x_value))
                        )
                    ]
                )
                polygon.stroke_width = 1
                polygon.set_stroke(WHITE)
                polygons.append(polygon)

            return VGroup(graph, *polygons, dist_text)

        graph = always_redraw(get_graph)
        self.add(axes, graph, x_label, y_label)

        self.wait()
        self.play(t.animate.set_value(END_VALUE), run_time=3, rate_func=linear)
        self.wait()

Licensing

[edit]
I, the copyright holder of this work, hereby publish it under the following license:
w:en:Creative Commons
attribution share alike
This file is licensed under the Creative Commons Attribution-Share Alike 4.0 International license.
You are free:
  • to share – to copy, distribute and transmit the work
  • to remix – to adapt the work
Under the following conditions:
  • attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  • share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.

File history

Click on a date/time to view the file as it appeared at that time.

Date/TimeThumbnailDimensionsUserComment
current15:31, 7 October 20235.0 s, 1,920 × 1,080 (853 KB)A potato hater (talk | contribs)Uploaded own work with UploadWizard

There are no pages that use this file.

Transcode status

Update transcode status
Format Bitrate Download Status Encode time
VP9 1080P 1.89 Mbps Completed 15:32, 7 October 2023 15 s
VP9 720P 981 kbps Completed 15:32, 7 October 2023 11 s
VP9 480P 543 kbps Completed 15:32, 7 October 2023 9.0 s
VP9 360P 305 kbps Completed 15:32, 7 October 2023 5.0 s
VP9 240P 176 kbps Completed 15:32, 7 October 2023 6.0 s
WebM 360P 347 kbps Completed 15:32, 7 October 2023 5.0 s
QuickTime 144p (MJPEG) Not ready Unknown status

File usage on other wikis

The following other wikis use this file:

Metadata