File:Conditional norm.svg

Uploaded by A potato hater
Upload date 2024-01-12T17:42:12Z
MIME type image/svg+xml
Dimensions 576 × 432 px
File size 30.7 KB

Summary

Description
Беларуская: Параўнанне шчыльнасці і функцыі размеркавання з умоўнымі шчыльнасцю і функцыяй размеркавання, для нармальнага размеркавання пры ўмове X > 0.
English: Comparison between regular PDF and CDF and conditional PDF and CDF for normal distribution. The condition is X > 0.
Date
Source Own work
Author A potato hater

Python Script

from matplotlib import gridspec
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm


linspace_size = 5000
linspace_left = -4
linspace_right = 4
x = np.linspace(linspace_left, linspace_right, linspace_size)
pdf = norm.pdf(x, 0)
pdf_cond = norm.pdf(x, 0) * 2
pdf_cond[x <= 0] = 0
cdf = np.cumsum(pdf) / (linspace_size / (linspace_right - linspace_left))
cdf_cond = np.cumsum(pdf_cond) / (linspace_size / (linspace_right - linspace_left))

fig = plt.figure()
gs = gridspec.GridSpec(2, 1)
ax0 = plt.subplot(gs[0])
plt.plot([], [], ' ', label="$X \sim \mathcal{N}(0, 1)$", color="black")
plt.plot(x, pdf, label="$f_X$")
plt.plot(x, pdf_cond, label="$f_{X|\{X>0\}}$")
plt.legend(prop={"size": 14})
plt.tick_params(
    axis='x', 
    which='both',
    bottom=False,      
    top=False,         
    labelbottom=False)

ax1 = plt.subplot(gs[1], sharex = ax0)
plt.plot(x, cdf, label="$F_X$")
plt.plot(x, cdf_cond, label="$F_{X|\{X>0\}}$")
plt.legend(prop={"size": 14})
plt.subplots_adjust(hspace=.05)

plt.savefig('plots/conditional_norm.svg')

Licensing

I, the copyright holder of this work, hereby publish it under the following license:
Creative Commons CC-Zero This file is made available under the Creative Commons CC0 1.0 Universal Public Domain Dedication.
The person who associated a work with this deed has dedicated the work to the public domain by waiving all of their rights to the work worldwide under copyright law, including all related and neighboring rights, to the extent allowed by law. You can copy, modify, distribute and perform the work, even for commercial purposes, all without asking permission.

Captions

Add a one-line explanation of what this file represents

Items portrayed in this file

depicts

12 January 2024

image/svg+xml

dfbaaf0023039fc7f3998cb80bf895f5e9be0c23

31,433 byte

432 pixel

576 pixel

Category:CC-Zero Category:Conditional probability Category:Self-published work