@@ -0,0 +1,1891 @@
+#Author : Pranav Jain%0A%0A#!/usr/bin/python%0A# -*- coding : utf-8 -*-%0A%0A%0Aimport random%0A%0A%0Adef appliance_switching():%0A    %0A    NUMBER_OF_RANDOMS = 5           # Number of random numbers for each appliance%0A%0A    list_of_appliances = %5B'ac', 'tv', 'light' , 'fan'%5D  # Finite List of appliances %0A%0A    dict_of_appliances = %7B%7D              # The dictionary to hold the random streams of the appliances%0A%0A    for i in list_of_appliances:         %0A        dict_of_appliances%5Bi%5D = %5Brandom.randint(0, 200) for j in range(NUMBER_OF_RANDOMS)%5D%0A%0A    #print dict_of_appliances             # Debugging Statement%0A%0A    #print dict_of_appliances%5B'tv'%5D       # Debugging Statement%0A%0A    %0A    dict_of_switch = %7B%7D                   # The dicitonary to hold the switiching event information%0A%0A    for x in dict_of_appliances:%0A        dict_of_switch%5Bx%5D = mark_switch_event(dict_of_appliances%5Bx%5D)%0A%0A    #print dict_of_appliances           # debugging statement%0A    #print dict_of_switch               # debugging statment%0A%0A%0A    bitwise_and(dict_of_switch)%0A%0A        %0A%0Adef mark_switch_event(random_stream):%0A    %22%22%22Function to detect switching . Takes as input the random data stream associated with each appliance%22%22%22%0A    temp = %5B%5D %0A    for i in range(len(random_stream)-1):%0A        t_1 = random_stream%5Bi%5D   %0A        t = random_stream%5Bi-1%5D%0A        if abs(t - t_1)%3E40:%0A            temp.append(1)%0A        else:%0A            temp.append(0)%0A    return temp%0A%0A%0Adef bitwise_and(dictionary):%0A    %22%22%22Function to detect switching . Takes as input the dictionary of switiching %22%22%22%0A    jlt = %5B%5D %0A    for x in dictionary:%0A        zipped = list(zip(*dictionary.values()))%0A%0A    #print zipped    # debugging statement%0A%0A    for i in zipped:%0A        jlt.append(all(i))%0A%0A    #print jlt  # debugging statement%0A        %0A    cnt = 0%0A    for iterator in jlt:%0A        if iterator == True:%0A            cnt = cnt + 1%0A%0A    print cnt%0A%0A%0A%0A%0Aappliance_switching()%0A

Create appliance_switch.py