% Delivered to the Government in Accordance with Contract FA8650-10-C-7080
% 
%  (c) 2011 United Technologies Corp.
% Developed with the sponsorship of the Defense Advanced Research Projects Agency (DARPA).
%  
% Permission is hereby granted, free of charge, to any person obtaining a copy of this data, including any software or models in source or binary form, as well as any drawings, specifications, and documentation (collectively "the Data"), to deal in the Data without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Data, and to permit persons to whom the Data is furnished to do so, subject to the following conditions:
%  
% The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Data.
%  
% THE DATA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS, SPONSORS, DEVELOPERS, CONTRIBUTORS, OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA OR THE USE OR OTHER DEALINGS IN THE DATA.
% 

clear all
clc

Mach = 0.8;
T_amb = 216.15;
P_amb = 22729;

global gam_cold 

gam_cold = 1.4;

num_samples = 10000;

sigma_Ta = 12;
sigma_Pa = 600;
sigma_M = .0289;

a = sqrt(3)*sigma_Ta;
T_amb = T_amb-a + 2*a*rand(num_samples,1);

a = sqrt(3)*sigma_Pa;
P_amb = P_amb-a + 2*a*rand(num_samples,1);

a = sqrt(3)*sigma_M;
Mach = Mach-a + 2*a*rand(num_samples,1);

[T1 P1] = Diffuser(T_amb,P_amb, Mach);

plot(T_amb,P_amb,'.b',T1,P1,'r.');

epa_diffuser = ( std(T1)/mean(T1) + std(P1)/mean(P1) ) / ...
    ( std(P_amb)/mean(P_amb) + std(T_amb)/mean(T_amb) + std(Mach)/mean(Mach) ) 


mean(T1)
std(T1)
mean(P1)
std(P1)







