## 4 Monte Carlo Simulation
### MCS Implementation Notes  
Implementing MCS to solve the RTE requires a careful consideration of efficiency, accuracy, and maintainability. The logical approach for implementing MCS is to obtain a solution for RTE in any programming language like Python by defining the necessary implementation items that should be mapped to the equations derived in Section 4.1, i.e., the MCS Framework subsection. The following are the main work items:  
* Defining the Scope of the Modelling: Clearly define the use case to be solved, including the IOP set and associated events/impairments of the underlying seawater link,  
Figure 16: MCS PROJECT—functional viewpoint sequence diagram. boundary conditions, and the desired output (e.g., radiative flux, received optical intensity profile, and photon event distribution). * Design the Simulation based on the MSC Framework: Confirm the extent of the framework as discussed in Section 4.1. Following this is designing the simulation classes and associated data models. Based on that, the following viewpoints could be generated, context, information, and implementation (object, functional, and sequence diagrams), including the random sampling strategy (using SPF or full random selection) and associated PTA (e.g., Equations (63)-(78)), modelling the photon event set as in Equation (62), and statistical convergence criteria associated with used implementation Python or MATLAB libraries. * Parameter Initialisation: Set up initial parameters such as the number of photons/particles to simulate; the spatial domain set {optical beam colimitation, FOV}; optical properties as defined in Table 3, e.g., coefficients of the absorption, scattering, attenuation, and scattering albedo; and boundary conditions for the variables listed in Table 6.
* Photon Tracking: Implement the PTA to simulate the trajectory of individual photons through the medium (Equations (61), (63), (66) and (69)), handling photon interactions (absorption, scattering) based on Equations (69) and (70) and boundary interactions (reflection, transmission) according to physical principles. The channel class object handles this implementation item using two functions: _simulate_one_photon_travel_ and _simulate_photons_propagation_ (see Figure 15). To compute \(x\equiv\{n_{k,m},c_{k,m}\}\) in Equations (75)-(78), we need to define the type of the PDF for each of these random variables. It is logical to assume that these two parameters might have uniform distribution, which is easy to implement, or a Gaussian PDF \(f(x)\) and CDF \(\Phi(x)\). * MATLAB or Python: However, because of the importance of the Gaussian distribution, the values of the \(\Phi\) function have been tabulated in many manuals. However, we can compute \(\Phi(x)\) using the normcdf command in MATLAB to compute \(\Phi(x)\) for a given number \(x\). More specifically, _normcdf_(\(x\)) returns \(\Phi(x)\). Also, the MATLAB function _norminv_ returns \(\Phi(x)\). If we run \(x=norminv(y)\), then \(x\) will be the real number for which \(y=\Phi(x)\). In the case of using Python, then we can use _scipy.stats.norm.cdf_(\(x\)), or \((1+\textit{math.erf}(x/\textit{math.sqrt}(2.0)))/2\). The minimum and maximum values for x vs. the \(\lambda\) and temperature (\(T^{\circ}\)) can be found in [140]. The channel class object handles this implementation item inside a _simulate_one_photon_travel_ function (see Figure 15). * Scattering Models: Incorporate SPF models listed in Table 4 to simulate scattering events accurately. Ensure that the scattering model is appropriate for the scattering phase matrix and anisotropy of the medium. Modelling events like scintillation and turbulence as scattering-like events use Equation (3) instead of Equation (1). The channel class object function simulate_one_photon_travel handles this implementation item (see Figure 15).