I'm trying to write a function that will solve this question: What is the probability that the minimal die is 3 when 5 dice are cast?
I've run into this error AttributeError: 'int' object has no attribute 'min'
, and I can't figure out how to fix it. The code worked fine before I made it a function.
Here is my function:
import numpy as np
def minimal_throw(throws, rng, n_reps = 10 ** 5):
results = rng.integers(low = 1, high = 6 + 1, size = (n_reps, throws))
minimas = throws.min(axis = 1)
uniques, counts = np.unique(minimas, return_counts = True)
return {"face" : uniques, "probability" : counts / n_reps}
rng = np.random.default_rng()
simulated_throws = minimal_throw(5, rng = rng)
faces = simulated_throws["face"]
probabilities = simulated_throws["probability"]