Czjzek distribution Model

class mrsimulator.models.CzjzekDistribution(sigma: float, mean_isotropic_chemical_shift: float = 0.0, abundance: float = 100.0, polar=False, cache=True)

Bases: AbstractDistribution

A Czjzek distribution model class.

The Czjzek distribution model is a random sampling of second-rank traceless symmetric tensors whose explicit matrix form follows

(82)\[\begin{split}{\bf S} = \left[ \begin{array}{l l l} \sqrt{3} U_5 - U_1 & \sqrt{3} U_4 & \sqrt{3} U_2 \\ \sqrt{3} U_4 & -\sqrt{3} U_5 - U_1 & \sqrt{3} U_3 \\ \sqrt{3} U_2 & \sqrt{3} U_3 & 2 U_1 \end{array} \right],\end{split}\]

where the components, \(U_i\), are randomly drawn from a five-dimensional multivariate normal distribution. Each component, \(U_i\), is a dimension of the five-dimensional uncorrelated multivariate normal distribution with the mean of \(<U_i>=0\) and the variance \(<U_iU_i>=\sigma^2\).

(83)\[S_T = S_C(\sigma),\]

sigma (float) – The Gaussian standard deviation.


In the original Czjzek paper, the parameter \(\sigma\) is given as two times the standard deviation of the multi-variate normal distribution used here.


>>> from mrsimulator.models import CzjzekDistribution
>>> cz_model = CzjzekDistribution(0.5)
add_lmfit_params(params, i)

Create lmfit params for index i

pack_csdm_object(pos, data)

Pack data and coordinates as csdm objects

pdf(pos, size: int = 400000, analytical: bool = True, pack_as_csdm: bool = False)

Generates a probability distribution function by binning the random variates of length size onto the given grid system.

  • pos – A list of coordinates along the two dimensions given as NumPy arrays.

  • size – The number of random variates drawn in generating the pdf. The default is 400000.

  • pack_as_csdm – If true, returns as csdm object.


A list of x and y coordinates and the corresponding amplitudes if not packed as csdm object, else a csdm object.


>>> import numpy as np
>>> cq = np.arange(50) - 25
>>> eta = np.arange(21)/20
>>> amp = cz_model.pdf(pos=[cq, eta])  # returns amp as a CSDM object.
pdf_numerical(pos, size: int = 400000)

Generate distribution numerically

rvs(size: int)

Draw random variates of length size from the distribution.


size – The number of random points to draw.


A list of two NumPy array, where the first and the second array are the anisotropic/quadrupolar coupling constant and asymmetry parameter, respectively.


>>> Cq_dist, eta_dist = cz_model.rvs(size=1000000)
update_lmfit_params(params, i)

Update lmfit params for index i