NB. Isotropic scattering of a beam incident on a slab. NB. Usage: (T; mu_i; hnmu) Uslab k; nscat NB. Here, T=slab thickness, hnmu= number of (positive) mu bins NB. k= number of Monte Carlo scattering photons, scatter "nscat" times NB. mu_i= cos(theta), theta is the angle of incident beam to normal NB. since this is a lambda-iteration, we must set nscat >> T^2 MC_beam=: dyad define 'T mu_i hnmu'=. x T2=. -: T NB. optical depth to midplane nmu=. +: hnmu NB. total (positive and negative) mu bins 'k nscat'=. y NB. number of initial photons and scatterings Int=. k# Fscat=: F T%mu_i NB. Set Int to fraction of beam scattered z=. T2- mu_i*Dt Fscat*rand k NB. z of initially scattered photons fret=: _1+ 2*int01 nmu NB. frets to divide -1Su;Sd NB. plot emergent intensities