diff --git a/mathgenerator/mathgen.py b/mathgenerator/mathgen.py index 1ab79bb..64f6668 100644 --- a/mathgenerator/mathgen.py +++ b/mathgenerator/mathgen.py @@ -726,7 +726,6 @@ def quadraticEquation(maxVal=100): solution = str([round((-b+D)/(2*a), 2),round((-b-D)/(2*a), 2)]) return problem,solution - def hcfFunc(maxVal=20): a = random.randint(1, maxVal) b = random.randint(1, maxVal) @@ -764,7 +763,28 @@ def exponentiationFunc(maxBase = 20,maxExpo = 10): problem = f"{base}^{expo} =" solution = str(base ** expo) return problem, solution - + +def confidenceIntervalFunc(): + n=random.randint(20,40) + j=random.randint(0,3) + lst=random.sample(range(200,300),n) + lst_per=[80 ,90, 95, 99] + lst_t = [1.282, 1.645, 1.960, 2.576] + mean=0 + sd=0 + for i in lst: + count= i + mean + mean=count + mean = mean/n + for i in lst: + x=(i-mean)**2+sd + sd=x + sd=sd/n + standard_error = lst_t[j]*math.sqrt(sd/n) + problem= 'The confidence interval for sample {} with {}% confidence is'.format([x for x in lst], lst_per[j]) + solution= '({}, {})'.format(mean+standard_error, mean-standard_error) + return problem, solution + # || Class Instances #Format is: @@ -817,10 +837,11 @@ vectorCross = Generator("Cross Product of 2 Vectors", 43, "a X b = ", "c", vecto compareFractions=Generator("Compare Fractions",44,"Which symbol represents the comparison between a/b and c/d?",">/