'''
This code is developed by professor Jørn Vatn. The code can be used
by students and employees at NTNU. The code comes with no warranties.

You are not allowed to use the code for commercial purposes without
written permission from Jørn Vatn
'''
import math
def betaDiscrete(i,a,b):  
   from scipy.stats import beta
   return beta.cdf((i+1)/6,a,b)-beta.cdf(i/6,a,b)
characters = ["A","B","C","D","E","F"]
alpha = 2
beta = 5
print("******\nDiscretizing the beta distribution with alpha =",alpha,"and beta =", beta)
print("\nMean:",alpha/(alpha+beta))
print("SD:",math.sqrt(alpha*beta/((alpha+beta)**2*(alpha+beta+1))))
for i, ch in enumerate(characters):
   print(ch+":","{:.2%}".format(betaDiscrete(i,alpha,beta)))
