irfpy.util.isotropy
¶
Functions for isotropic distribution
|
Return the randomly generated distribution |
|
Return the randomly generated distribution in |
- irfpy.util.isotropy.getRandom_tp(size=None)[source]¶
Return the randomly generated distribution in
and- Parameters:
size – The size of the array.
- Returns:
Randomly generated isotropic distribution. (theta, phi) = retval in radians
- Return type:
(2, size[0], size[1], …)-shaped numpy array.
>>> rnd = getRandom_tp() >>> rnd.shape (2,)
>>> rnd = getRandom_tp(size=(2, 4)) # (3, 2, 4) array will be returned. >>> rnd.shape (2, 2, 4)
Way of generation
The polar angle,
, should distribute considering the area at spherical surface, namely depending on . To realize this, one can start from uniform random, convert it according towhere P is the (array of) value generated from random distribution.
The azimuth angle,
, is random in the range of (0, 2 ).
- irfpy.util.isotropy.getRandom(size=None)[source]¶
Return the randomly generated distribution
- Parameters:
size – The size of the array.
- Returns:
Randomly generated isotropic distribution. Unit vector.
- Return type:
(3, size[0], size[1], …)-shaped numpy array.
>>> np.random.seed(0) # Set the random seed. >>> rnd = getRandom() >>> rnd.shape (3,)
>>> print('{:.3f}'.format((rnd ** 2).sum())) 1.000
>>> rnd = getRandom(size=(2, 4)) # (3, 2, 4) array will be returned. >>> rnd.shape (3, 2, 4)
Way of generation
The polar angle,
, should distribute considering the area at spherical surface, namely depending on . To realize this, one can start from uniform random, convert it according towhere P is the (array of) value generated from random distribution.
The azimuth angle,
, is random in the range of (0, 2 ).