function generate_pdfs(filename)

fid = fopen(filename, 'rt');
L = readline(fid);
PMetMetSA   = [];
PMetRocSA   = [];
PMetMwSA    = [];
PMwMetSA    = [];
PMetMetSRGI = [];
PMetRocSRGI = [];
PMetMwSRGI  = [];
PMwMetSRGI  = [];
PMwRocSA    = [];
PMwRocSRGI  = [];

PMetIceSnowSRGI = [];

EntropySRGI = [];
EntropySAll = [];

while (L > 0)
%while (0)
   [class,L] = strtok(L);
   [s1,L] = strtok(L); PMetRGI = str2num(s1);
   [s2,L] = strtok(L); PMwRGI  = str2num(s2);
   [s3,L] = strtok(L); EntropyRGI = str2num(s3);
   [s4,L] = strtok(L); PMetAll = str2num(s4);
   [s5,L] = strtok(L); PMwAll  = str2num(s5);
   [s6,L] = strtok(L); EntropyAll = str2num(s6);
   
   EntropySRGI = [EntropySRGI EntropyRGI];
   EntropySAll = [EntropySAll EntropyAll];
   
   if strcmpi('meteorite',class)
      PMetMetSA = [PMetMetSA PMetAll];
      PMetMetSRGI = [PMetMetSRGI PMetRGI];
      
      PMwMetSA = [PMwMetSA PMwAll];
      PMwMetSRGI = [PMwMetSRGI PMwRGI];
   end
   
   if strcmpi('rock',class)
      PMetRocSA = [PMetRocSA PMetAll];
      PMetRocSRGI = [PMetRocSRGI PMetRGI];
      
      PMwRocSA = [PMwRocSA PMwAll];
      PMwRocSRGI = [PMwRocSRGI PMwRGI];

   end
   
   if strcmpi('meteorong',class)
      PMetMwSA = [PMetMwSA PMetAll];
      PMetMwSRGI = [PMetMwSRGI PMetRGI];
   end
   
   if strcmpi('ice',class) | strcmpi('snow',class)
      PMetIceSnowSRGI = [PMetIceSnowSRGI, PMetRGI+PMwRGI];
   end
   
L = readline(fid);
end

%fclose(fid);
%save temp PMetMetSA PMetRocSA PMetMwSA PMwMetSA PMetMetSRGI PMetRocSRGI PMetMwSRGI PMwMetSRGI PMwRocSA PMwRocSRGI
%load temp

% generate pdf's using parzen estimation
X = 0:0.001:1;
dx = [0 diff(X)];
sigma = 0.005;

% Entropy
PEntropyRGI = parzen_pdf(X,EntropySRGI,sigma);
PEntropyAll = parzen_pdf(X,EntropySAll,sigma);

% P(Meteorite|Class = Meteorite)
PMMA = parzen_pdf(X,PMetMetSA,sigma);
PMMRGI = parzen_pdf(X,PMetMetSRGI,sigma);

PMetAsNotMetA = cumsum(PMMA).*dx;
PMetAsNotMetRGI = cumsum(PMMRGI).*dx;

% P(Meteorite|Class = Rock)
PMRA = parzen_pdf(X,PMetRocSA,sigma);
PMRRGI = parzen_pdf(X,PMetRocSRGI,sigma);

PRockAsMetA = 1 - cumsum(PMRA).*dx;
PRockAsMetRGI = 1 - cumsum(PMRRGI).*dx;

% P(Meteorite|Class = Meteorong)
PMMwA = parzen_pdf(X,PMetMwSA,sigma);
PMMwRGI = parzen_pdf(X,PMetMwSRGI, sigma);

PMwAsMetA = 1 - cumsum(PMMwA).*dx;
PMwAsMetRGI = 1 - cumsum(PMMwRGI).*dx;

% P(Meteorong|Class = Meteorite)
PMwMA = parzen_pdf(X,PMwMetSA, sigma);
PMwMRGI = parzen_pdf(X,PMwMetSRGI, sigma);

PMetAsMwA = 1 - cumsum(PMwMA).*dx;
PMetAsMwRGI = 1 - cumsum(PMwMRGI).*dx;

% P(Meteorong|Class = Rock)
PMwRA = parzen_pdf(X, PMwRocSA, sigma);
PMwRRGI  = parzen_pdf(X, PMwRocSRGI, sigma);

PRockAsMwA = 1-cumsum(PMwRA).*dx;
PRockAsMwRGI = 1-cumsum(PMwRRGI).*dx;

% P(Meteorite OR Meteorong|Class = Snow OR Ice)
PMiceRGI = parzen_pdf(X,PMetIceSnowSRGI, sigma);

%plot the buggers

% all sensors
figure(1);
plot(X,PMMA,'r.-',X,PMRA,'k.-',X,PMMwA,'b.-');
legend('P(met|met)','P(met|rock)','P(met|meteorong)');
title('All Data');

figure(2);
plot(X,PMetAsNotMetA,'r.-',X,PRockAsMetA,'k.-',X, PMwAsMetA,'b.-',X,PRockAsMwA,'c.-',X,PMetAsMwA,'m.-');
legend('Met as ~Met', 'Rock as Met', 'Mw as Met', 'Rock as Mw', 'Met as Mw');
title('Error Rate, All Data');

figure(3);
plot(X,PMMRGI,'r.-',X,PMRRGI,'k.-',X,PMMwRGI,'b.-');
legend('P(met|met)','P(met|rock)','P(met|meteorong)');
title('RED GREEN BLUE Data only');

figure(4);
plot(X,PMetAsNotMetRGI,'r.-',X,PRockAsMetRGI,'k.-',X, PMwAsMetRGI,'b.-',X,PRockAsMwRGI,'c.-',X,PMetAsMwRGI,'m.-');
legend('Met as ~Met', 'Rock as Met', 'Mw as Met', 'Rock as Mw', 'Met as Mw');
title('Error Rate, RED GREEN BLUE Data');

figure(5);
plot(X,PEntropyRGI,'r.-',X,PEntropyAll,'b.-');
legend('Entropy after Color Measurement', 'Entropy after Color and Spectr Measurement');
title('Entropy Distribution');



