[huh yr mo day hr ozone]=textread('mlo_O3_6m_hour_2014.txt','%d%d%d%d%d%f');
figure(1);
histogram(ozone);
xlabel('Hourly Ozone Concentrations (ppb)');
ylabel('# of hours');

[huh yr mo day hr ozone]=textread('mlo_O3_6m_6am_2014.txt','%d%d%d%d%d%f');
size(ozone)
figure(2);
histogram(ozone);
xlabel('6 AM Ozone Concentration (ppb)');
ylabel('# of days');

[huh yr mo day hr ozone]=textread('mlo_O3_6m_hour_2014.txt','%d%d%d%d%d%f');
ozone = ozone(7:24:end);
size(ozone)
figure(3);
histogram(ozone, 'binWidth', 5);
xlabel('Hourly Ozone Concentrations (ppb)');
ylabel('# of hours');

% bimodal data
[huh yr mo day hr ozone]=textread('mlo_O3_6m_hour_2014.txt','%d%d%d%d%d%f');
ozone = [ ozone(1:3:end)+40; ozone(2:3:end); ozone(3:3:end) ];
figure(4);
histogram(ozone,'BinWidth',2);
xlabel('Hourly Ozone Concentrations (ppb)');
ylabel('# of hours');

%symmetric data
ozone = 40+20*randn(4000,1);
figure(5);
histogram(ozone,'BinWidth',2);

% skewed data
ozone = 40+3*exp(randn(4000,1))+5*randn(4000,1);
figure(6);
histogram(ozone,'BinWidth',2);

[huh yr mo day hr ozone]=textread('mlo_O3_6m_6am_2014.txt','%d%d%d%d%d%f');
figure(7);
histogram(ozone, 'BinWidth', 1);
xlabel('6 AM Ozone Concentration (ppb)');
ylabel('# of days');
%
oz_sorted = sort(ozone);
[n,m] = size(ozone);
(oz_sorted(floor((n+1)/2)) + oz_sorted(ceil((n+1)/2)))/2
%
median(ozone)
mode(round(ozone))
mean(ozone)
sum(ozone)/n

'range'
max(ozone)-min(ozone)

'iqr'
oz_sorted = sort(ozone);
[n,m] = size(ozone);
(oz_sorted(round(0.75*n)) ...
- oz_sorted(round(0.25*n)))

% Matlab's builtin function
iqr(ozone)

std(ozone)

sum(abs(ozone-mean(ozone)))/n

x = ozone;
xbar = mean(x);
s = std(x);
[n,m] = size(x);
figure(8);
histogram(x, 'binWidth', 5);
hold on;
xx = 0:100;
pdfx = 5*n*pdf('norm',xx, xbar, s);
plot(xx,pdfx,'b-');
xlabel('Hourly Ozone Concentrations (ppb)');
ylabel('# of hours');
hold off;

x_sorted = sort(x);
'min'
minx = min(x)
'Q1'
q1 = x_sorted(round(0.25*n))
'Median'
q2 = median(x)
'Q3'
q3 = x_sorted(round(0.75*n))
'max'
maxx = max(x)
[huh yr mo day hr ozone]=textread('mlo_O3_6m_6am_2014.txt','%d%d%d%d%d%f');
size(ozone)
figure(9);
%histogram(ozone);
%hold on;
boxplot(x,'orientation','horizontal');
title('6 AM Ozone Concentration');
xlabel('(ppb)');
set(gca,'ytick',[]);
hold off;

