monte_carlos - Functions and Toy MC

powspechi.monte_carlos.fconst(x)

Constant function.

Parameters

x (float, array_like) – Independent variable.

Returns

1 – Output value, always 1.

Return type

float, scalar

powspechi.monte_carlos.fct_sin(x, sfct, *args, **kwargs)

Multiply a function by \(\sin{(x)}\).

Parameters
  • x (float, array_like) – Independent variable.

  • sfct (function) – The chosen function to be multiplied by \(\sin{(x)}\).

  • *args – Arguments to be passed to sfct.

  • **kwargs – Keyword-only arguments to be passed to sfct.

Returns

y – Output value associated with multiplying sfct by \(\sin{(x)}\). Its shape is the same as x.

Return type

float, ndarray

Notes

When picking a random polar point from a function defined on a sphere, just using sfct will not yield the right result. It is therefore necessary to pick a point from \(\sin{(x)}\). For a more detailed explanation, check ‘Sphere Point Picking’ on the internet or a text book.

powspechi.monte_carlos.ffexp(x)

A function symmetric around \(\pi/2\), which is also the value associated with the function’s minimum.

Parameters

x (float, array_like) – Independent variable.

Returns

y – Output value whose shape is the same as x.

Return type

float, ndarray

powspechi.monte_carlos.fphi_psi(x, vns=None, psis=None)

A function (Fourier expansion) based on the flow ansatz used in heavy-ion studies 1 2. It has the following expression:

\[h(x) = \frac{1}{2\pi} \left[ 1 + 2\sum_{n = 1}^{\infty} v_n \cos[n(x - \Psi_n)] \right],\]

where \(v_n,\Psi_n\) are the amplitude and phase, respectively.

Parameters
  • x (float, array_like) – Independent variable.

  • vns (float, array_like, optional) – Amplitudes of the Fourier expansion. If not given, it will be taken as zero. Default: None.

  • psis (float, array_like, optional) – Phases of the Fourier expansion. If not given, it will be taken as zero. Default: None.

Returns

y – Output of the function. It has the same shape as x.

Return type

float, array_like

References

1
  1. Voloshin and Y. Zhang, “Flow study in relativistic nuclear collisions by Fourier expansion of azimuthal particle distributions”, Z. Phys. C70, 665 (1996).

2

A.M. Poskanzer and S.A. Voloshin, “Methods for analyzing flow in relativistic nuclear collisions”, Phys. Rev. C58, 1671 (1998).

powspechi.monte_carlos.from_fct(fct, size, xmin=0.0, xmax=1.0, *args, **kwargs)

Draw random values according to a chosen 1-D function within a specified interval.

Parameters
  • fct (function) – Chosen function.

  • size (int, scalar) – Desired number of samples.

  • xmin (float, scalar, optional) – Lower boundary of the interval. Default: 0.

  • xmax (float, scalar, optional) – Upper boundary of the interval. Output values will be less than xmax. Default: 1.

  • *args – Arguments to be passed to fct.

  • **kwargs – Keyword-only arguments to be passed to fct.

Returns

samples – A 1-D array whose length is determined by size. It contains random values distributed according to fct.

Return type

float, ndarray

powspechi.monte_carlos.isodist(mult, etacut=None)

Create an isotropic particle distribution with specified multiplicity and limitation in \(\theta\).

Parameters
  • mult (int, scalar) – Multiplicity or size of the output sample.

  • etacut (float, scalar, optional) – Limit imposed on pseudorapidity (or polar angle), i.e., \(|\eta|\) < etacut. Default: None.

Returns

angs – A 2-D array with shape (mult, 2). Under column 0 are the azimuthal angles, while under column 1 are the polar angles.

Return type

float, ndarray

Notes

In order to pick a random number on the surface of a sphere, azimuthal and polar angles are drawn, respectively, from the following expressions:

\[\begin{split}\phi = 2\pi u,\\\end{split}\]
\[\theta = \arccos{(2v - 1)},\]

where \(u,v\) are random variables within the interval (0, 1).