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
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
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');