import torch
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
%matplotlib inline
# Retina display
%config InlineBackend.figure_format = 'retina'
import warnings
'ignore')
warnings.filterwarnings(import arviz as az
from tueplots import bundles
plt.rcParams.update(bundles.beamer_moml())
# Also add despine to the bundle using rcParams
'axes.spines.right'] = False
plt.rcParams['axes.spines.top'] = False
plt.rcParams[
# Increase font size to match Beamer template
'font.size'] = 16
plt.rcParams[# Make background transparent
'figure.facecolor'] = 'none' plt.rcParams[
class SimplePRNG:
def __init__(self, seed=0):
self.seed = seed
self.a = 1664525
self.c = 1013904223
self.m = 2**32
def random(self):
self.seed = (self.a * self.seed + self.c) % self.m
return self.seed / self.m
def generate_N_random_numbers(self, N):
= []
random_numbers for _ in range(N):
self.random())
random_numbers.append(return random_numbers
# Usage
= SimplePRNG(seed=42) # You can change the seed value
prng = 10000 # Change N to the number of random numbers you want to generate
N = prng.generate_N_random_numbers(N)
random_numbers
= plt.hist(random_numbers, bins=10) _
=False) az.plot_kde(np.array(random_numbers), rug
<AxesSubplot:>
= plt.hist(np.random.rand(10000), bins=10) _
10000), rug=False) az.plot_kde(np.random.rand(
<AxesSubplot:>
### Uniform (a, b)
= -2
a = 2
b
= a + (b - a) * np.array(random_numbers) random_numbers_a_b
=10) plt.hist(random_numbers_a_b, bins
(array([1006., 1012., 963., 964., 1008., 939., 1039., 1012., 1031.,
1026.]),
array([-1.99864224e+00, -1.59883546e+00, -1.19902869e+00, -7.99221917e-01,
-3.99415144e-01, 3.91628593e-04, 4.00198402e-01, 8.00005174e-01,
1.19981195e+00, 1.59961872e+00, 1.99942549e+00]),
<BarContainer object of 10 artists>)