<jupyter_start><jupyter_text>Maxwell-Boltzmann Distribution<jupyter_code>import numpy as np
from matplotlib import pyplot as plt
%matplotlib inline

def plot_distribution(x,y,xlabel,ylabel):
    """Plot the x and y values of a distribution."""
    # Plotting parameters
    fgs = (12,8)     # figure size
    lw = 8           # line width
    lfs = 18         # label font size
    tfs = 16         # tick font size
    xlp,ylp = 30,50  # label padding
    ylr = 0          # y-axis label rotation
    # Generate the plot
    fig,ax = plt.subplots(figsize=fgs)
    plt.plot(x,y,linewidth=lw)
    plt.tick_params(labelsize=tfs)
    plt.xlabel(xlabel,fontsize=lfs,labelpad=xlp)
    plt.ylabel(ylabel,fontsize=lfs,rotation=ylr,labelpad=ylp)
    plt.tight_layout()
    return fig,ax
# Function parameters
npoints = 1001

m = 1
k = 8.6173303e-5 # eV/K
T = 293          # K<jupyter_output><empty_output><jupyter_text>Energy<jupyter_code>E = np.linspace(0,0.2,npoints)
M_E = 2*np.sqrt(E/np.pi)*(1/(k*T))**(3/2)*np.exp(-E/(k*T))
# Plot the Maxwell-Boltzmann distribution for energy
figE,axE = plot_distribution(E,M_E,'$E$','$M(E)$')
# Plot a vertical line at the most probably energy, E = k*T
E_p = k*T*np.ones(200)
y = np.arange(0,20,0.1)
axE.plot(0.5*E_p,y,'g')
#plt.savefig('mb-dist_E.png')<jupyter_output><empty_output><jupyter_text>Speed<jupyter_code>v = np.linspace(0,0.8,npoints)
M_v = 4*np.pi*v**2*(m/(2*np.pi*k*T))**(3/2)*np.exp(-m*v**2/(2*k*T))
# Plot the Maxwell-Boltzmann distribution for speed (blue)
figv,axv = plot_distribution(v,M_v,'$v$','$M(v)$')
# Overlay the distribution for speed converted to energy (orange)
E_v = 0.5*m*v**2
axv.plot(E_v,M_v,linewidth=8)
# Plot a vertical line at the most probably energy, E = k*T
axv.plot(E_p[:40],y[:40],'g')
#plt.savefig('mb-dist_v.png')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16327652556349642, 'fraction_numerical': 0.035733919736118745, 'mean_word_length': 4.321637426900585, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '549415', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 807, 'n_tokens_neox': 756, 'n_words': 142, 'path': 'notebooks/mb-dist.ipynb', 'repo_name': 'mitchnegus/NE150-discussion', 'size': '1819'}