Started with PreferenceExpectedImprovement.py

This commit is contained in:
Niko Feith 2023-07-12 13:52:06 +02:00
parent 2ffaa3aead
commit c8d4022cd4
2 changed files with 44 additions and 0 deletions

View File

@ -0,0 +1,19 @@
import numpy as np
from scipy.stats import norm
class PreferenceExpectedImprovement:
def __init__(self):
pass
def rejection_sampling(self):
pass
def expected_improvement(self):
pass
def update_user_preference_model(self):
pass
def update_proposal_model(self):
pass

25
DistTesting/Testing.py Normal file
View File

@ -0,0 +1,25 @@
import numpy as np
import matplotlib.pyplot as plt
# Define the Gaussian distribution
mu, sigma = 0, 5 # High variance
gaussian = np.random.normal(mu, sigma, 1000000) # Generate a lot of samples
# Rejection sampling
gaussian = gaussian[(gaussian > -1) & (gaussian < 1)]
# Generate uniform distribution
uniform = np.random.uniform(-1, 1, len(gaussian)) # Same number of samples as the Gaussian
# Plot the distributions
plt.figure(figsize=(12,6))
plt.subplot(1, 2, 1)
plt.hist(gaussian, bins=30, density=True, alpha=0.6, color='g')
plt.title('Gaussian Rejection Sampling')
plt.subplot(1, 2, 2)
plt.hist(uniform, bins=30, density=True, alpha=0.6, color='b')
plt.title('Uniform Distribution')
plt.show()