close all
clear all
%-----------------------------------
  disp('IgE Serum Concentration')
  lw = 3; 
  set(0, 'DefaultAxesFontSize', 17);
  fs = 17;
  msize = 20;

%  Total serum IgE (immunoglobulin E) concentration allergy tests allow for
% measurement of the total IgE level in a serum sample. Elevated levels of 
% IgE are associated with the presence of the allergy. An example of testing
% for total serum IgE is the PRIST (paper radioimmunosorbent test). This test
% involves serum samples  reacting with IgE that has been tagged with 
% radioactive iodine.
% Bound radioactive iodine, calculated upon completion of the test procedure,
% is proportional to the amount of total IgE in the serum sample.
% The determination of the normal IgE levels in a population of healthy 
% non-allergenic individuals varies by the fact that some individuals may 
% have subclinical allergies and therefore have abnormal serum IgE levels.
% The log-concentration of IgE (in IU/ml) in a cohort of healthy subjects
% is distributed as a normal N(9, (0.9)^2) random variable.
% What is the probability that in a randomly selected subject from the same
% cohort,  the log-concentration:
%
% (1)**** Exceeds 10 IU/ml?
% 
% (2)**** Is between 8.1 and 9.9 IU/ml?
% 
% (3)**** Differs from the mean by no more than 1.8 IU/ml?
% 
% (4)**** Find the number  x_0, so that
% the IgE log-concentration in 90% of the
% subjects from the same cohort exceeds  x_0. 
% 
% (5)**** In what bounds (symmetric about the mean) the IgE
% log-concentration falls with the probability 0.95?
% 
% (6)**** If IgE log-concentration is   N(9, sigma^2), find
%  sigma  so that P(8 <= X <= 10)=0.64. 
% 



%(1)
 % P(X>10)= 1-P(X <= 10)
1-normcdf(10,9,0.9)  %or >>  1-normcdf((10-9)/0.9)
% ans =   0.1333
%(2)
%P(8.1 <= X <= 9.9)
 %P((8.1-9)/0.9 <= Z <= (9.9-9)/0.9)
 %P(-1 <= Z <= 1) ::: Note 1-sigma rule.
normcdf(9.9, 9, 0.9) - normcdf(8.1, 9, 0.9)
%or, normcdf((9.9-9)/0.9)-normcdf((8.1-9)/0.9)
% ans =    0.6827
 %(3)
%P(9-1.8 <= X <= 9+1.8) = P(-2 <= Z <= 2)
 %Note 2-sigma rule.
normcdf(9+1.8, 9, 0.9) - normcdf(9-1.8, 9, 0.9)
% ans =    0.9545
%(4)
%0.90 = P(X > x_0)=1-P(X <= x0)
%that is P(Z <= (x0-9)/0.9)=0.1
norminv(1-0.9,   9, 0.9)
%ans =    7.8466
%(5)
%P(9-delta <= X <= 9+delta)=0.95
[9-0.9*norminv(1-0.05/2), 9+0.9*norminv(1-0.05/2)]
%   ans =  7.2360   10.7640
%(6)
%P(-1/sigma) <= Z <= 1/sigma)=0.64
%note that 0.36/2 + 0.64 + 0.36/2 = 1
1/norminv( 1 - 0.36/2 )
%  ans = 1.092

