[SciPy-Dev] Proposal for a new scipy.special function: Voigt

Johann Goetz theodore.goetz at gmail.com
Sun Sep 23 18:15:46 EDT 2018


This is good as I've always thought scipy.special could use a dedicated
Voigtian distribution. I am curious though how it compares (both
mathematically and performance) with the code I've been using for this:

# The Voigt probability distribution
# where the integral from -inf to inf is equal to one
# voigt_pdf(mean, sigma, gamma)(x)
def voigt_pdf(mean,sigma,gamma):
    def voigt_pdf_fn(x,mean=mean,sigma=sigma,gamma=gamma):
        z = ((x-mean) + 1j*gamma) / (sigma * np.sqrt(2))
        return sp.special.wofz(z).real / (sigma * np.sqrt(2.*np.pi))
    return voigt_pdf_fn

# Voigt distribution
# with total integral as the first parameter
# voigt(x, N, mean, sigma, gamma)
def voigt(x, N, mean, sigma, gamma):
    return N * voigt_pdf(mean,sigma,gamma)(x)

-- Johann

On Sun, Sep 23, 2018 at 3:04 PM Muhammad Firmansyah Kasim <
firman.kasim at gmail.com> wrote:
> I am proposing to implement a new special function under `scipy.special`
module: Voigt function.
> Voigt function/profile is a very common line profile in atomic
transitions and widely used in the spectroscopy field. It is a convolution
between Gaussian and Cauchy distribution, thus it is not trivial to
calculate it efficiently.
> There are several approximations to calculate it efficiently, but I am
proposing to use the one in the "Stellar atmosphere" by Mihalas (1978). It
is the one used in FLYCHK by NIST and IAEA (I work closely with the author
of the code).
> Please let me know if you have any suggestions or objections to the
proposal.
> Thanks!
>
> Muhammad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20180923/4cfd78e8/attachment.html>


More information about the SciPy-Dev mailing list