Exemplo n.º 1
0
 def interpret_exponential(self,recordings,confidence=False,minute_interval=10,days=False):
         durations=[]
         if days==True:
             max_val=1440*7
         else:
             max_val=1440
         for recording in recordings:
             try:
                 durations.append(recording.time.seconds+recording.time.microseconds/10**6.)
             except AttributeError:
                 durations.append(0)
         if (len(durations)==0):
             partitions=[]
             lambdas=[]
             if confidence==True:
                 cons=[]
             for i in range(0,max_val/minute_interval):
                 partitions.append(i*minute_interval)
                 lambdas.append(0)
                 if confidence==True:
                     cons.append(sys.maxint)
             partitions.append(max_val)
             if confidence==True:
                 return partitions, lambdas, cons
             else:
                 return partitions, lambdas
         total_average= sum(durations)/len(durations)
         times_of_day=[]
         for recording in recordings:
             if days==True:
                 times_of_day.append(recording.date.day*60*24+recording.date.hour*60+recording.date.minute)
             else:
                 times_of_day.append(recording.date.hour*60+recording.date.minute)
         e = exponential()
         if confidence == True:
             (partitions,lambdas,confidences)=e.calculate_distribution(durations,times_of_day,minute_interval,confidence,days)
         else:
             (partitions,lambdas)=e.calculate_distribution(durations,times_of_day,days=days)
         expected_values=[]
         for l in lambdas:
             if l >0:
                 expected_values.append(1/l)
             else:
                 expected_values.append(0)
         
         if confidence == True:
             return partitions, expected_values,confidences
         else:
             return partitions,expected_values
Exemplo n.º 2
0
def menu():
    print("1-Addition \t\t 2-Subtration \t\t 3-Multiply \t\t 4-Division")
    print("5-Sin() \t\t 6-Cos() \t\t 7-Tan() \t\t 8-Sec()")
    print("9-Cosec() \t\t 10-Cot() \t\t 11-Square \t\t 12-Square Root \t\t")
    print("13-Power \t\t 14-Root \t\t 15-Expontial(e^x)")
    print("16-Factorial \t\t 17-log()\t\t 18-ln() \t\t 19-Quadratic Eq Solver")
    print(
        "20-Inverse(x^-1) \t 21-Sin inverse \t 22-Cos Inverse \t 23.Tan Inverse"
    )
    print("24-Permutation \t\t 25-Combination \t 26-Percentage")
    print("27-Multiple Basic Operators At a time \t\t 28-Close")

    while True:
        try:
            choice = int(input("Enter your choice(press number):"))
            break
        except ValueError:
            print("Input must be a number!")
    if choice == 1:
        while True:
            Sum.Sum()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 2:
        while True:
            Sub.sub()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 3:
        while True:
            Mul.multiply()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 4:
        while True:
            divide.divide()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 5:
        while True:
            sin.sin()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 6:
        while True:
            cos.cos()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 7:
        while True:
            tan.tan()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 8:
        while True:
            sec.sec()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 9:
        while True:
            cosec.cosec()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 10:
        while True:
            cot.cot()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 11:
        while True:
            square.square()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 12:
        while True:
            sqrt.sqrt()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 13:
        while True:
            power.power()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 14:
        while True:
            root.root()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 15:
        while True:
            exponential.exponential()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 16:
        while True:
            factorial.factorial()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 17:
        while True:
            log.log()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 18:
        while True:
            ln.ln()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 19:
        while True:
            quadratic.quadratic()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 20:
        while True:
            inverse.inv()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 21:
        while True:
            asin.asin()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 22:
        while True:
            acos.acos()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 23:
        while True:
            atan.atan()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 24:
        while True:
            per.per()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 25:
        while True:
            com.com()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 26:
        while True:
            percentage.percentage()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 27:
        while True:
            combine()
            x = int(input("press 1 to try again,press 2 to return to menu"))
            if x == 1:
                continue
            if x == 2:
                menu()
                break
    elif choice == 28:
        close()
    else:
        print("Invalid Input.Try Again")
        menu()
Exemplo n.º 3
0
def calculator():
    print('\tWELOCME TO OUR SCIENTIFIC CALCULATOR......')
    print('\t==========================================')
    print('''
1. Addition                   2. Subtraction                        3. Multiplication
4. Division                   5. Square                             6. Cube
7. Square root                8. Cube root                          9. log
10. Antilog                   11. Nth Root                          12. Nth Power
13. Factorial                 14. Matrix(2x2)                       15. Matrix(3x3)
16. ln                        17. Reciprocal                        18. Percentage
19. Exponential               20. Quadratic Equation                21. Sin()
22. Cos()                     23. Tan()                             24. Sinh
25. Cosh                      26. Tanh
27. Length Conversion       28.Temperature Conversion         29. Angle Conversion
30. Permutation                 31. Combination ''')

    #calculator()
    while True:
        choice = int(input('Please choose from the following given options!'))
        if choice == 1:
            import simple
            simple.add()
        elif choice == 2:
            import simple
            simple.subtract()
        elif choice == 3:
            import simple
            simple.multiply()
        elif choice == 4:
            import simple
            simple.divide()
        elif choice == 5:
            import Square
            Square.square()
        elif choice == 6:
            import Cube
            Cube.cube()
        elif choice == 7:
            import square_root
            square_root.square_root()
        elif choice == 8:
            import cube_root
            cube_root.cube_root()
        elif choice == 9:
            import log
            log.log()
        elif choice == 10:
            antilog.antilog()
        elif choice == 11:
            import nth_root
            nth_root.nth_root()
        elif choice == 12:
            import nth_power
            nth_power.nth_power()
        elif choice == 13:
            import factorial
            factorial.factorial()
        elif choice == 14:
            import matrix
            matrix.matrix()
        elif choice == 15:
            matrix_3()
        elif choice == 16:
            ln.ln()
        elif choice == 17:
            import reciprocal
            reciprocal.reciprocal()
        elif choice == 18:
            import Percentage
            Percentage.percentage()
        elif choice == 19:
            import exponential
            exponential.exponential()
        elif choice == 20:
            import quadratic_eq
            quadraric_eq.Quadratic()
        elif choice == 21:
            import sine
            sine.sin()
        elif choice == 22:
            import cosine
            cosine.cos()
        elif choice == 23:
            import tangent
            tangent.tan()
        elif choice == 24:
            import sinh
            sinh.sinh()
        elif choice == 25:
            import cosh
            cosh.cosh()
        elif choice == 26:
            import tanh
            tanh.tanh()
        elif choice == 27:
            import length_converter
            length_converter.length_converter()
        elif choice == 28:
            import Temp_converter
            Temp_converter.temperature_converter()
        elif choice == 29:
            import angle_converter
            angle_converter.rad()
            angle_converter.deg()
        elif choice == 30:
            import Combination
            Combination.npr(x, y)
        elif choice == 31:
            import Combination
            Combination.ncr(x, y)
        elif choice == 32:
            import mod
            mod.mod()
Exemplo n.º 4
0
 def test_case_of_3_to_the_0(self):
     """
     exponential(3,0) should be 1
     """
     self.assertEqual(exponential(3,0), 1)
Exemplo n.º 5
0
 def test_case_of_2_to_the_3(self):
     """
     exponential(2,3) should be 8
     """
     self.assertEqual(exponential(2,3), 8)