Created
September 7, 2017 15:44
-
-
Save rosiel/0bf950537eb5324fccad3d73063400e4 to your computer and use it in GitHub Desktop.
Hypothesis: it's more likely to be cloudy given that yesterday was cloudy, than that the day before yesterday was cloudy.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/python3 | |
import csv | |
dates = [] | |
cloudyvalues = [] | |
pattern = [] | |
pattern3 = [] | |
thisdate = '11-5-2005' | |
thissky = [] | |
counter = 1 | |
with open ('data.csv', 'r') as csvfile: | |
myreader = csv.reader(csvfile, delimiter=',') | |
for row in myreader: | |
counter = counter + 1 | |
if counter > 100000: | |
break | |
[date, time] = row[0].split(' ') | |
if time not in set(['20:00:00', '21:00:00', '22:00:00']): | |
continue | |
if not date.startswith('9'): | |
continue | |
if date != thisdate: | |
# Evaluate the last cloudiness and clear it | |
cloudy = 0 | |
for value in thissky: | |
if value < 5: | |
cloudy = 1 | |
dates.append(date) | |
if len(cloudyvalues) > 0: | |
pattern.append(str(cloudyvalues[-1]) + str(cloudy)) | |
if len(cloudyvalues) > 1: | |
pattern3.append(str(cloudyvalues[-2]) + str(cloudy)) | |
cloudyvalues.append(cloudy) | |
thissky = [] | |
thisdate = date | |
thissky.append(int(row[2])) | |
for i in range(len(pattern3)): | |
print(dates[i], pattern3[i]) | |
print("Total days counted: ", len(dates)) | |
print("Cloudy days counted: ", cloudyvalues.count(1)) | |
print("P(cloudy): ", cloudyvalues.count(1)/len(dates)) | |
print("\n") | |
print("Total days after cloudy days: ", pattern.count('11') + pattern.count('10')) | |
print("Cloudy days following cloudy days: ", pattern.count('11')) | |
print("P(cloudy|yesterday was cloudy): ", pattern.count('11') / (pattern.count('11') + pattern.count('10'))) | |
print("\n") | |
print("Total days, where before yesterday was cloudy: ", pattern3.count('11') + pattern3.count('10')) | |
print("Cloudy days where before yesterday was cloudy: ", pattern3.count('11')) | |
print("P(cloudy|before yesterday was cloudy): ", pattern3.count('11') / (pattern3.count('11') + pattern3.count('10'))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment