0

I am being asked to output the probability of a number most repeated for every dice until dice N rolled P times. The code I have now is:

import random
N = int(input("Insert Number: "))
P = int(input("Insert Number again: "))
for x in range (1,N+1):
    print("Dice",x)
    n = random.sample(range(1,6), P)
    print(n)

Can someone help me move on to the step to calculate the possibility of the most repeated number for each dice?

Red
  • 26,798
  • 7
  • 36
  • 58

1 Answers1

0

This isn't really a python question per se as much as a probability question. That notwithstanding, there are basically two methods that readily come to mind.

  1. Exact Solution - You can enumerate all of the possible sums combinations of dice for N dice, then find every possible permutation of these sum combinations, and then perform a simple check to determine which of the permutations satisfy the condition that the designated value is the most common sum of dice.

  2. Monte Carlo Simulations - You can simulate the rolling of N dice, P times, and record the most commonly rolled sum. Repeat this a sufficiently large number of times and then use the result to estimate the probability.

DerekG
  • 3,555
  • 1
  • 11
  • 21