ParaMonte Fortran 2.0.0
Parallel Monte Carlo and Machine Learning Library
See the latest version documentation.
pm_distBand::setBandUCDF Interface Reference

Generate and return the unnormalized cumulative distribution function (UCDF) of the Band spectral model/distribution.
More...

Detailed Description

Generate and return the unnormalized cumulative distribution function (UCDF) of the Band spectral model/distribution.

See the documentation of pm_distBand for more information on the Band distribution.
The UCDF of the Band model is the integral of its UDF over a range \((\ms{lb}, \ms{ub})\) written as,

\begin{equation} \large \ms{UCDF}_\ms{BAND} = \int_{\ms{lb}}^{\ms{ub}} f_{\ms{BAND}}(E | \alpha, \beta, \ebreak) dE ~. \end{equation}

where \(f_{\ms{BAND}}\) is the UDF of the Band distribution.

While the integration domain should be ideally \([0, +\infty)\), the arbitrary values of \(\alpha\) and \(\beta\) require finite bounds for the integral to be specified by user to ensure convergence.

Parameters
[out]ucdf: The output scalar or array of the same shape as any input array-like argument, of type real of kind any supported by the processor (e.g., RK, RK32, RK64, or RK128) as the input argument ucdf, containing the distribution UCDF.
[in]lb: The input positive scalar or array of the same shape as any input array-like argument, of the same type and kind as the input argument ucdf, representing the lower bound of the Band distribution.
[in]ub: The input positive scalar or array of the same shape as any input array-like argument, of the same type and kind as the input argument ucdf, representing the upper bound of the Band distribution.
[in]alpha: The input scalar or array of the same shape as other array-like arguments of the same type and kind as ucdf, containing the first shape parameter of the distribution.
[in]beta: The input scalar or array of the same shape as other array-like arguments of the same type and kind as ucdf, containing the second shape parameter of the distribution.
[in]ebreak: The input scalar or array of the same shape as other array-like arguments of the same type and kind as ucdf, containing the normalized spectral break energy values: \(\ebreak = \frac{\ebreak}{100\kev}\).
[out]info: The output scalar of type integer of default kind IK.
On output, it is set to positive the number of iterations taken for the series representation of the Gamma function to converge.
If the algorithm fails to converge, then info is set to the negative of the number of iterations taken by the algorithm or, to the output error returned by brute force integrator getQuadErr.
An negative output value signifies the lack of convergence and failure to compute the UCDF.
This is likely to happen if the input value for alpha or beta are too extreme.


Possible calling interfaces

call setBandUCDF(ucdf, lb, ub, alpha, beta, ebreak, info)
Generate and return the unnormalized cumulative distribution function (UCDF) of the Band spectral mod...
This module contains procedures and generic interfaces for computing the Band photon distribution wid...
Definition: pm_distBand.F90:97
Warning
The condition 0 < lb must hold for the corresponding input arguments.
The condition 0 < ub must hold for the corresponding input arguments.
The condition alpha /= -2 must hold for the corresponding input arguments.
The condition 0 < ebreak must hold for the corresponding input arguments.
The condition 0 < invEfold must hold for the corresponding input arguments.
The condition beta < alpha must hold for the corresponding input arguments.
The condition ebreak = (alpha - beta) * invEfold must hold for the corresponding input arguments.
The condition zeta = getZeta(alpha, beta, ebreak) must hold for the corresponding input arguments.
These conditions are verified only if the library is built with the preprocessor macro CHECK_ENABLED=1.
Remarks
The procedures under discussion are impure.
The procedures under discussion are elemental.
Note
The normalization (and the physical units) of the input energy is irrelevant as long as the input values ebreak and zeta are computed in the same physical dimensions and with the same normalizations.
See also
getBandUDF
setBandUCDF
setBandMean
getBandZeta
getBandEpeak
getBandEbreak
setBandPhoton
setBandEnergy


Example usage

1program example
2
3 use pm_kind, only: SK, IK, LK
4 use pm_kind, only: RKG => RKH ! all processor kinds are supported.
5 use pm_io, only: display_type
6 use pm_distBand, only: setBandUCDF
7
8 implicit none
9
10 real(RKG) :: ucdf(4)
11 integer(IK) :: info(4)
12 type(display_type) :: disp
13 disp = display_type(file = "main.out.F90")
14
15 call disp%skip()
16 call disp%show("call setBandUCDF(ucdf(1), lb = .01_RKG, ub = 10._RKG, alpha = +2._RKG, beta = -3._RKG, ebreak = 1._RKG, info = info(1))")
17 call setBandUCDF(ucdf(1), lb = .01_RKG, ub = 10._RKG, alpha = +2._RKG, beta = -3._RKG, ebreak = 1._RKG, info = info(1))
18 call disp%show("if (info(1) < 0) error stop")
19 if (info(1) < 0) error stop
20 call disp%show("ucdf(1)")
21 call disp%show( ucdf(1) )
22 call disp%skip()
23
24 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
25 ! Output an example array for visualization.
26 !%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
27
28 block
29
30 use pm_arraySpace, only: setLinSpace
31 integer(IK) , parameter :: NP = 1000_IK
32 real(RKG) :: ucdf(4), ub(NP)
33 integer :: fileUnit, i
34
35 call setLinSpace(ub, 0.01_RKG, 10._RKG)
36 open(newunit = fileUnit, file = "setBandUCDF.RK.txt")
37 do i = 1, NP
38 call setBandUCDF(ucdf, 0.01_RKG, ub(i), [.5_RKG, 1.5_RKG, -.5_RKG, -1.1_RKG], -[.5_RKG, 1._RKG, 2._RKG, 3._RKG], [.5_RKG, 1.0_RKG, 2.0_RKG, 5._RKG], info = info)
39 if (any(info < 0)) error stop
40 write(fileUnit, "(*(g0,:,' '))") ub(i), ucdf
41 end do
42 close(fileUnit)
43
44 end block
45
46end program example
Return the linSpace output argument with size(linSpace) elements of evenly-spaced values over the int...
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11726
This is a generic method of the derived type display_type with pass attribute.
Definition: pm_io.F90:11508
This module contains procedures and generic interfaces for generating arrays with linear or logarithm...
This module contains classes and procedures for input/output (IO) or generic display operations on st...
Definition: pm_io.F90:252
type(display_type) disp
This is a scalar module variable an object of type display_type for general display.
Definition: pm_io.F90:11393
This module defines the relevant Fortran kind type-parameters frequently used in the ParaMonte librar...
Definition: pm_kind.F90:268
integer, parameter LK
The default logical kind in the ParaMonte library: kind(.true.) in Fortran, kind(....
Definition: pm_kind.F90:541
integer, parameter IK
The default integer kind in the ParaMonte library: int32 in Fortran, c_int32_t in C-Fortran Interoper...
Definition: pm_kind.F90:540
integer, parameter SK
The default character kind in the ParaMonte library: kind("a") in Fortran, c_char in C-Fortran Intero...
Definition: pm_kind.F90:539
integer, parameter RKH
The scalar integer constant of intrinsic default kind, representing the highest-precision real kind t...
Definition: pm_kind.F90:858
Generate and return an object of type display_type.
Definition: pm_io.F90:10282

Example Unix compile command via Intel ifort compiler
1#!/usr/bin/env sh
2rm main.exe
3ifort -fpp -standard-semantics -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example Windows Batch compile command via Intel ifort compiler
1del main.exe
2set PATH=..\..\..\lib;%PATH%
3ifort /fpp /standard-semantics /O3 /I:..\..\..\include main.F90 ..\..\..\lib\libparamonte*.lib /exe:main.exe
4main.exe

Example Unix / MinGW compile command via GNU gfortran compiler
1#!/usr/bin/env sh
2rm main.exe
3gfortran -cpp -ffree-line-length-none -O3 -Wl,-rpath,../../../lib -I../../../inc main.F90 ../../../lib/libparamonte* -o main.exe
4./main.exe

Example output
1
2call setBandUCDF(ucdf(1), lb = .01_RKG, ub = 10._RKG, alpha = +2._RKG, beta = -3._RKG, ebreak = 1._RKG, info = info(1))
3if (info(1) < 0) error stop
4ucdf(1)
5+0.173405303729200175851483190089853506E-1
6
7

Postprocessing of the example output
1#!/usr/bin/env python
2
3import matplotlib.pyplot as plt
4import pandas as pd
5import numpy as np
6import glob
7import sys
8
9fontsize = 17
10
11kind = "RK"
12label = [ r"$\alpha, \beta = +0.5, -0.5, x_b = 0.5, \mathrm{lb} = .01$"
13 , r"$\alpha, \beta = +1.5, -1.0, x_b = 1.5, \mathrm{lb} = .01$"
14 , r"$\alpha, \beta = -0.5, -2.0, x_b = 2.0, \mathrm{lb} = .01$"
15 , r"$\alpha, \beta = -1.1, -3.0, x_b = 5.0, \mathrm{lb} = .01$"
16 ]
17
18pattern = "*." + kind + ".txt"
19fileList = glob.glob(pattern)
20if len(fileList) == 1:
21
22 df = pd.read_csv(fileList[0], delimiter = " ")
23
24 fig = plt.figure(figsize = 1.25 * np.array([6.4, 4.8]), dpi = 200)
25 ax = plt.subplot()
26
27 for i in range(1,len(df.values[0,:]+1)):
28
29 plt.plot( df.values[:, 0]
30 , df.values[:,i] / df.values[-1,i]
31 , linewidth = 2
32 )
33
34 plt.xticks(fontsize = fontsize - 2)
35 plt.yticks(fontsize = fontsize - 2)
36 ax.set_xlabel(r"$\mathrm{ub}$", fontsize = fontsize)
37 ax.set_ylabel("Normalized Band UCDF", fontsize = fontsize)
38
39 plt.grid(visible = True, which = "both", axis = "both", color = "0.85", linestyle = "-")
40 ax.tick_params(axis = "y", which = "minor")
41 ax.tick_params(axis = "x", which = "minor")
42
43 ax.legend ( label
44 , fontsize = fontsize
45 #, loc = "center left"
46 #, bbox_to_anchor = (1, 0.5)
47 )
48
49 plt.savefig(fileList[0].replace(".txt",".png"))
50
51else:
52
53 sys.exit("Ambiguous file list exists.")

Visualization of the example output
Test:
test_pm_distBand


Final Remarks


If you believe this algorithm or its documentation can be improved, we appreciate your contribution and help to edit this page's documentation and source file on GitHub.
For details on the naming abbreviations, see this page.
For details on the naming conventions, see this page.
This software is distributed under the MIT license with additional terms outlined below.

  1. If you use any parts or concepts from this library to any extent, please acknowledge the usage by citing the relevant publications of the ParaMonte library.
  2. If you regenerate any parts/ideas from this library in a programming environment other than those currently supported by this ParaMonte library (i.e., other than C, C++, Fortran, MATLAB, Python, R), please also ask the end users to cite this original ParaMonte library.

This software is available to the public under a highly permissive license.
Help us justify its continued development and maintenance by acknowledging its benefit to society, distributing it, and contributing to it.

Author:
Amir Shahmoradi, Oct 16, 2009, 11:14 AM, Michigan

Definition at line 815 of file pm_distBand.F90.


The documentation for this interface was generated from the following file: