Here is a Python program that simulates the relationship between binary probability (BP) and the order parameter (M) for a system with N = 1000 marbles. The simulation models the distribution of marbles between two bins (left and right) as a function of the binary probability BP, with BP controlling the likelihood of a marble falling to the left or right.
We calculate the order parameter M, which is the difference in the number of marbles on the left (N1) and right (N2) normalized by the total number of marbles.
simulate_phase_transition(N, BP_values):
This function simulates the dropping of N marbles for a range of binary probabilities (BP).
For each BP value, we use a binomial distribution to simulate how many marbles land in the left bin (N1). The remaining marbles fall into the right bin (N2=N−N1).
The order parameter (M) is calculated as M=(N1−N2)/(N1+N2), which measures the difference in the number of marbles on either side.
N = 1000:
We simulate 1000 marbles being dropped.
BP_values = np.linspace(0, 1, 100):
We generate 100 binary probability values, evenly spaced between 0 and 1, to model the rod angle in the Plinko experiment.
4. Plot 1:
Generate the BP vs. N1 and BP vs. N2 plots, which will show the number of marbles falling to the left (N1) and right (N2) bins as the binary probability (BP) varies.
import numpy as np
import matplotlib.pyplot as plt
# Function to simulate marble drops and return N1 and N2
def simulate_N1_N2(N, BP_values):
N1_list = []
N2_list = []
for BP in BP_values:
# Simulate N marbles being dropped with probability BP to the left
N1 = np.random.binomial(N, BP) # Number of marbles to the left
N2 = N - N1 # Number of marbles to the right
N1_list.append(N1)
N2_list.append(N2)
return N1_list, N2_list
# Parameters
N = 1000 # Number of marbles
BP_values = np.linspace(0, 1, 100) # BP values from 0 to 1 in 100 steps
# Run the simulation to get N1 and N2
N1_list, N2_list = simulate_N1_N2(N, BP_values)
# Plot BP vs N1 and N2
plt.figure(figsize=(8, 6))
plt.plot(BP_values, N1_list, label='N1 (Marbles on Left)', color='r')
plt.plot(BP_values, N2_list, label='N2 (Marbles on Right)', color='g')
plt.title('BP vs N1 and N2 for N = 1000')
plt.xlabel('Binary Probability (BP)')
plt.ylabel('Number of Marbles (N1, N2)')
plt.grid(True)
plt.legend()
plt.show()
4 Plot 2:
The binary probability (BP) is plotted against the order parameter (M), showing how the distribution of marbles changes as BP varies.
Output:
The output is a graph showing the relationship between BP and the order parameter (M). When BP = 0.5, the system is symmetric (M = 0), and as BP approaches 0 or 1, the system becomes asymmetric, with M approaching +1 or -1.
This simulation provides an intuitive way to visualize how the system transitions from symmetry to asymmetry, mimicking a phase transition.
import numpy as np
import matplotlib.pyplot as plt
# Function to simulate marble drops and calculate the order parameter (M)
def simulate_phase_transition(N, BP_values):
order_params = []
for BP in BP_values:
# Simulate N marbles being dropped with probability BP to the left
N1 = np.random.binomial(N, BP) # Number of marbles to the left
N2 = N - N1 # Number of marbles to the right
# Calculate the order parameter M
M = (N1 - N2) / (N1 + N2) # (N1 - N2) / (N1 + N2) normalizes the difference
order_params.append(M)
return order_params
# Parameters
N = 1000 # Number of marbles
BP_values = np.linspace(0, 1, 100) # BP values from 0 to 1 in 100 steps
# Run the simulation
order_params = simulate_phase_transition(N, BP_values)
# Plot BP vs Order Parameter
plt.figure(figsize=(8, 6))
plt.plot(BP_values, order_params, label='Order Parameter (M)')
plt.title('BP vs Order Parameter for N = 1000')
plt.xlabel('Binary Probability (BP)')
plt.ylabel('Order Parameter (M)')
plt.grid(True)
plt.legend()
plt.show()