File size: 2,317 Bytes
5ab75a9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
function Fb = estimateFb(Mb,Mmd,Flo,Mlo,Fhi,Mhi)
% estimateFb - Estimate fraction brighter than threshold
% Syntax: Fb = estimateFb(Mb,Mmd,Flo,Mlo,Fhi,Mhi);
%
% =========================================================================
%
% Copyright (c)�2024�United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================
%
% Description: Calculate fraction brighter than theshold Mb, assuming an 
% asymmetric Gaussian. 
%
% =========================================================================
%
% Input:
%
%    Mb  -  Magnitude threshold
%    
%    Mmd -  Median magnitude plus adjustment
%
%    Flo -  0.05 (percentile)
%
%    Mlo -  5th percentile magnitude plus adjustment
%
%    Fhi -  0.95 (percentile)
%
%    Mhi -  95th percentile magnitude plus adjustment
% 
% =========================================================================
%
% Output:
%
% �� Fb - Fraction brighter than threshold Mb  
%
% =========================================================================
%
% Initial version: Nov�2024;� Latest update: Nov�2024
%
% ----------------- BEGIN CODE -----------------

% Calculate the Gaussian sigma value either above or below the median
sqrt2 = sqrt(2);
if Mmd >= Mb
    sig = (Mlo-Mmd)/sqrt2/erfinv(-1+2*Flo);
else
    sig = (Mhi-Mmd)/sqrt2/erfinv(-1+2*Fhi);
end

% Calculate the fraction of magnitudes in the asym Gaussian that are
% brighter than Mb
Xb = (Mb-Mmd)/sig/sqrt2;
Fb = 0.5*(1+erf(Xb));

return
end

% ----------------- END OF CODE ------------------
%
% Please record any changes to the software in the change history
% shown below:
%
% ----------------- CHANGE HISTORY ------------------
% Developer |���� Date��� | Description
% ---------------------------------------------------
% D. Hall��� |� 2024-Nov �| Initial version.
% =========================================================================
%
% Copyright (c)�2024�United States Government as represented by the
% Administrator of the National Aeronautics and Space Administration.
% All Rights Reserved.
%
% =========================================================================