Julia
Solving for Spherical Harmonic Analysis Quadrature Weights
In “More Notes on Calculating the Spherical Harmonics”, I used a simple iterative approach to converge on relatively accurate analysis of coefficients from a pixelized image on the sphere. In this article, we will look at the other method to improve the accuracy of approximating integration with finite sums by including so-called quadrature weight factors.
Spherical Harmonic Transforms on Ring-based Pixelizations
In two previous articles, I described the details of performing spherical harmonic synthesis and analysis using an equidistant cylindrical projection (ECP) pixelization scheme as the assumed map format. In this article, I’ll describe the generalizations to the algorithms which permit supporting the transform of any “ring-based” pixelization of the sphere.
More Notes on Calculating the Spherical Harmonics
This article is a long-overdue follow up to Notes on Calculating the Spherical Harmonics which considers the analysis of real-space map on the sphere to its spherical harmonic coefficients.
Basic D&D Statistics: Dice Rolling with Advantage
In the previous part of this series, we explored how to build the probability distributions for sums of dice rolls. That is sufficient for a great fraction of dice rolling in D&D, but a critical extra case to be considered are rolls made with advantage or disadvantage. In this article, we investigate how to extend our definitions to include die rolls with (dis)advantage.
Basic D&D Statistics: Sums of Dice Rolls
Being reliant on the roll of the dice, actions and outcomes in Dungeons and Dragons are fundamentally tied to probability and statistics. In this article I explore how the sums of dice are related to discrete probability distributions, building up from the case of a single die up to combining any arbitrary set of dice. The quantitative tools we develop will be sufficient to make basic assessments on the (un)likeliness of a given observed outcome.
Prefaulting Memory Mapped Arrays in Julia
One of the key facts about memory maps is that the mapping is performed asynchronously, with the data being loaded on demand as it is used. In some cases, though, we may know that the entire mapped region will be required — and only at the end of some other long-running process — so that there would be an advantage to expending some parallel effort to prefault the entire mapping into memory. In this article I motivate such a use case, and then I explore two separate ways of achieving the prefaulting behavior.
Convenient sentinels for keyword arguments in Julia
When writing a high-level interface function that takes many keyword options, the desired default values may sometimes be best set conditionally based on the values of other keywords. In such a case, handling the interdependency among keywords can be easiest if the function declaration uses a sentinel value like
nothing
, but then the type restrictions must be rewritten toUnion{T, Nothing}
in every case, which can get tedious. With a relatively simple macro, though, we can automate this transformation.Numerically computing the exponential function with polynomial approximations
Numerically computing any non-trivial function (spanning the trigonometric functions through to special functions like the complex gamma function) is a large field of numerical computing, and one I am interested in expanding my knowledge within. In this article, I describe my recent exploration of how the exponential function can be implemented numerically.
Notes on Calculating the Spherical Harmonics
In this article I review the critical properties of the Spherical Harmonics. In particular, I concentrate on filling in a couple of details regarding numerical computation of the spherical harmonic transformations that I have found to be unstated or less clear than ideal in the literature.
Introducing Legendre.jl
The Legendre.jl package accumulates the features shown throughout this series (and more) into a package expressly designed for calculating numerically accurate Legendre polynomials in a performant manner. In this article I formally introduce the package and demonstrate how it can be used to quickly prototype a couple of useful computations that I have encountered in CMB analysis.
Maintaining numerical accuracy in the Legendre recurrences
An algorithm for calculating special functions is no use if it has poor numerical accuracy and returns inaccurate or invalid answers. In this article I discuss the importance of using fused multiply-add (FMA) and a form of loop-unrolling to maintain numerical accuracy in calculating the associated Legendre polynomials to degrees and orders of order 1000 and greater.
Pre-normalizing Legendre Polynomials
In the previous part we computed Legendre polynomials via a few recurrence relations, but the polynomial values grow rapidly with degree and quickly overflow the range of standard finite floating point numbers. In this posting we explore baking in a normalization factor into the recurrence relation — such as used when the Legendre polynomials are used to calculate the spherical harmonics — that eliminates the overflow.
Calculating Legendre Polynomials
The Associated Legendre Polynomials are implicitly defined as the solution to a second-order differential equation, but most practical uses require an efficient means of explicitly evaluating the functions for any degree, order, and argument. In this article I introduce the implementation used in Legendre.jl which is based on evaluating a series of recurrence relations.
Introduction to Associated Legendre Polynomials
The Associated Legendre Polynomials are an important set of functions in cosmic microwave background (CMB) research. In this first part of an upcoming series, I motivate the need for a new high-performance Julia package — Legendre.jl — which I am writing to recreate a key algorithm in my thesis research.
Image-based Color Palette
Building a color theme around a primary photo can be useful, but picking the “main” colors by hand can be a challenge. Thankfully using a couple of simple analysis techniques, we can extract a color palette automatically.