function variance = benford_variance ( )

%*****************************************************************************80
%
%% benford_variance() returns the variance of the Benford PDF.
%
%  Licensing:
%
%    This code is distributed under the MIT license.
%
%  Modified:
%
%    11 November 2022
%
%  Author:
%
%    John Burkardt
%
%  Reference:
%
%    Frank Benford,
%    The Law of Anomalous Numbers,
%    Proceedings of the American Philosophical Society,
%    Volume 78, pages 551-572, 1938.
%
%    Ted Hill,
%    The First Digit Phenomenon,
%    American Scientist,
%    Volume 86, July/August 1998, pages 358 - 363.
%
%    Ralph Raimi,
%    The Peculiar Distribution of First Digits,
%    Scientific American,
%    December 1969, pages 109-119.
%
%  Output:
%
%    real VARIANCE: the variance of the Benford PDF.
%
  mu = 0.0;
  for i = 1 : 9
    mu = mu + i * log10 ( ( i + 1 ) / i );
  end

  variance = 0.0;
  for i = 1 : 9
    variance = variance + log10 ( ( i + 1 ) / i ) * ( i - mu )^2;
  end

  return
end
