https://github.com/laszlokorte/random-variable
An interactive example of a function applied to a random variable showing the resulting distribution.
https://github.com/laszlokorte/random-variable
random-variables statistics
Last synced: 11 months ago
JSON representation
An interactive example of a function applied to a random variable showing the resulting distribution.
- Host: GitHub
- URL: https://github.com/laszlokorte/random-variable
- Owner: laszlokorte
- Created: 2022-01-17T17:38:24.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-04-03T14:00:10.000Z (about 4 years ago)
- Last Synced: 2025-05-15T08:11:48.236Z (about 1 year ago)
- Topics: random-variables, statistics
- Language: Svelte
- Homepage: https://tools.laszlokorte.de
- Size: 54.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README

[Live Demo](https://static.laszlokorte.de/random-variable/) | [Short demo video](https://www.youtube.com/watch?v=UGjjtJiGywk)
# Function applied to random variables
Applying a function to a random variable affects the resulting distribution. The colored rectangles represent the density of the random variable along the X axis. You can see how squaring the variable shifts all rectangles into the positive range. Each colored rectangles keeps its area but is stretched along the X axis by 2*x (the derivative of x2). Accordingly the height of each rectangle is compressed by 2*x to keep the area constant.
As x^2 is not injective multiple rectangles end up at the same target along the x axis. They simply stack on top of each other to represent the resulting probability density at each location.
Clicking on a single rectangle highlights its corresponding partner rectangle in the other distribution.
Lowering the number of bins makes the individual rectangles more recognizable but reduces the precision of the probability density.