6
$\begingroup$

If I have a 1D sequence of complex numbers with real and imaginary parts, how can I compute the histogram of this sequence? Do I separately compute the histogram of both the real and imaginary parts?

Moreover, if I get a 2D histogram of a sequence of complex numbers, how do I apply goodness of fit tests (such as the $\chi^2$ test) to compare two histograms of complex numbers?

Is there a good reference book on the computation of histograms of complex numbers?

How would such a histogram of complex numbers be visually represented?

$\endgroup$
  • 2
    $\begingroup$ Because a complex number $x + iy$ is--by definition--just the real ordered pair $(x,y)$, every one of these questions except the last is answered at stats.stackexchange.com/questions/19261/…. $\endgroup$ – whuber Aug 2 '12 at 19:47
  • $\begingroup$ @whuber: Thanks for putting the complex numbers in the same framework as multidimensional goodness of fit. Is there anything else that is done differently with the complex numbers? I would assume that the multidimensional $\chi^2$ test would also be applied to complex numbers as well. $\endgroup$ – Nicholas Kinar Aug 2 '12 at 19:58
  • 2
    $\begingroup$ Because complex numbers are the Euclidean plane endowed with a multiplication operation (which is a simultaneous scaling and twisting) and conjugation (which is a reflection), the only things that could possibly be done differently would be in problems where those operations are of interest. Typically they are involved when using complex numbers to represent directions or rotations. If that's your situation, you might want to investigate the subspecialty of directional statistics. $\endgroup$ – whuber Aug 2 '12 at 20:12
  • $\begingroup$ @whuber: Actually, my application is digital signal processing (DSP), where a filter kernel convolution is applied in the frequency domain by the multiplication of the complex number representing the filter kernel at a discrete frequency with the complex number of the frequency domain signal at a discrete frequency. I've never heard of directional statistics; that's a new term for me, and it is very neat. Thanks for posting this. $\endgroup$ – Nicholas Kinar Aug 2 '12 at 20:17
1
$\begingroup$

If I have a 1D sequence of complex numbers with real and imaginary parts, how can I compute the histogram of this sequence? Do I separately compute the histogram of both the real and imaginary parts?

A complex number is just an ordered pair of real numbers (i.e., a two-element vector of real numbers) with extended definitions of arithmetic operators like addition, multiplication, etc. Visualisation of a data set of complex numbers can be done just like any other data-set consisting of bivariate vectors of real numbers. It is important to treat the values as bivariate values, to retain any statistical relationships between the parts, so it is not generally a good idea to construct separate histograms of the real and imaginary parts.

The best way to visualise a vector of complex numbers is to generate the kernel density estimator (KDE) of this data and then visualise this using either a surface plot, a contour plot, or a heat plot, taken over the two-dimensions of the complex numbers. (A histogram is just a clunky version of a KDE; you are better off using a KDE with a smooth kernel that does not depend on arbitrary bin choices.) If you use a contour plot or heat plot you can easily superimpose a scatterplot of the data values, which allows you to see the raw data, plus the estimated density of that data. This is what I would recommend.

Here is an example of what this looks like when implemented in R. In this code we generate some random complex data, and plot a scatterplot of the data with contours from the KDE using the ggalt package. This gives a clear visualisation of the raw data, plus giving an outline of the contours of its estimated density.

#Generate random vector X consisting of n complex values
set.seed(1)
n   <- 100;
ARG <- 2*pi*runif(n);
MOD <- rgamma(n, shape = 2, scale = 10) + rgamma(n, shape = 5, scale = 12);
X   <- complex(modulus = MOD, argument = ARG);

#Generate scatterplot with KDE contours
library(ggplot2);
library(ggalt);
DATA <- data.frame(Real = Re(X), Imaginary = Im(X));
THEME <- theme(plot.title    = element_text(hjust = 0.5, size = 14, face = 'bold'),
               plot.subtitle = element_text(hjust = 0.5, face = 'bold'),
               axis.title.x  = element_text(hjust = 0.5, face = 'bold'),
               axis.title.y  = element_text(hjust = 0.5, face = 'bold'));
ggplot(DATA, aes(x = Real, y = Imaginary)) + THEME +
       geom_point(size = 4, alpha = 0.4) + geom_bkde2d(bandwidth = c(20, 20)) +
       ggtitle('Scatterplot of complex data values with kernel density contours');

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.