Calculate Contraharmonic Mean

Online calculator to calculate the contraharmonic mean of a data series

Contraharmonic Mean Calculator

Contraharmonic Mean

The contraharmonic mean is the ratio of sum of squares to sum of values. It is complementary to the harmonic mean and greater than the arithmetic mean.

Enter Data
Data values (separated by spaces or semicolons)
Result
Contraharmonic Mean:
Properties of Contraharmonic Mean

Important: x̄arithmetic ≤ x̄contraharmonic (greater than arithmetic mean). Favors larger values.

Square-Based Complementary to Harmonic Favors Large Values

Contraharmonic Mean Concept

The contraharmonic mean is the ratio of sum of squares to sum.
It favors larger values more strongly than the arithmetic mean.

Squares → Sums → Division 2 3 4 5 6 4 9 16 25 36 + + + + Σx² 90 20 (Σx) 4.5

Input Values Squares Contraharmonic Mean

What is the Contraharmonic Mean?

The contraharmonic mean is a less-known but important measure of position:

  • Definition: Sum of squares divided by sum of values
  • Calculation: C = Σ(xᵢ²) / Σ(xᵢ)
  • Complementary: To harmonic mean H: H · C = A²
  • Property: Always ≥ arithmetic mean
  • Application: Signal processing, image processing, statistics
  • Weighting: Strongly favors larger values

Calculating the Contraharmonic Mean

Calculation is done in four steps:

1. Square

Form squares:
x₁², x₂², ..., xₙ²

2. Sum Squares

Sum of squares:
S₂ = Σ(xᵢ²)

3. Sum Values

Sum of values:
S₁ = Σ(xᵢ)

4. Divide

Divide S₂ by S₁:
C = S₂ / S₁

Applications of Contraharmonic Mean

The contraharmonic mean finds application in specialized fields:

Signal Processing
  • Noise suppression (pepper noise)
  • Image smoothing and filtering
  • Contrast enhancement
  • Edge detection
Statistics and Mathematics
  • Estimation theory (robust against small values)
  • Averaging for skewed distributions
  • Complementary consideration to harmonic mean
  • Lehénian means (special case for r=1)

Formulas for Contraharmonic Mean

Contraharmonic Mean
\[C(x_1,...,x_n) = \frac{\sum_{i=1}^{n} x_i^2}{\sum_{i=1}^{n} x_i}\]

Sum of squares divided by sum of values

Explicit Form
\[C = \frac{x_1^2 + x_2^2 + ... + x_n^2}{x_1 + x_2 + ... + x_n}\]

Explicit representation without sum notation

Relationship to Other Means
\[H \cdot C = A^2\] \[C \geq A \geq G \geq H\]

Harmonic · Contraharmonic = Arithmetic²

For Two Values
\[C(x_1, x_2) = \frac{x_1^2 + x_2^2}{x_1 + x_2}\]

Simplified form for two values

Symbol Explanations
\(C\) Contraharmonic mean
\(x_i\) Individual data value
\(n\) Number of values
\(\sum\) Sum sign
\(H, A, G\) Harmonic, Arithmetic, Geometric
\(x_i^2\) Square of xᵢ

Example Calculations for Contraharmonic Mean

Example 1: Basic Calculation
Data: 2, 3, 4, 5, 6

Calculate: Contraharmonic mean of 5 values

1. Form Squares
\[2^2=4, 3^2=9\] \[4^2=16, 5^2=25, 6^2=36\]

Square all values

2. Form Sums
\[\sum x_i^2 = 4+9+16+25+36 = \color{blue}{90}\] \[\sum x_i = 2+3+4+5+6 = \color{blue}{20}\]

Sum of squares and sum of values

3. Calculate Mean
\[C = \frac{90}{20}\] \[= \color{blue}{4.5}\]

Divide sum of squares by sum

Example 2: Comparison of Means
Data: 1, 2, 8

Compare: All classical means

Harmonic
\[H = \frac{3}{\frac{1}{1}+\frac{1}{2}+\frac{1}{8}}\] \[\approx \color{blue}{1.68}\]

Smallest mean

Geometric
\[G = \sqrt[3]{1 \cdot 2 \cdot 8}\] \[= \sqrt[3]{16} \approx \color{blue}{2.52}\]

Second smallest

Arithmetic
\[A = \frac{1+2+8}{3}\] \[\approx \color{blue}{3.67}\]

Second largest

Contraharmonic
\[C = \frac{1+4+64}{1+2+8}\] \[= \frac{69}{11} \approx \color{blue}{6.27}\]

Largest mean

Important Order

H ≤ G ≤ A ≤ C: The contraharmonic mean (6.27) is the largest, followed by arithmetic (3.67), geometric (2.52), and harmonic (1.68) is the smallest.
Relationship: H · C = A² → 1.68 · 6.27 ≈ 10.5 ≈ 3.67² ≈ 13.5 (approximately, due to rounding)
Observation: The contraharmonic mean is strongly influenced by the largest value (8).

Example 3: Image Processing (Pepper Noise)
Pixel values: 120, 125, 0, 130, 122

One black pixel (0) = pepper noise in bright area

Arithmetic Mean
\[A = \frac{120+125+0+130+122}{5}\] \[= \frac{497}{5} = \color{red}{99.4}\]

Problem: The outlier (0) pulls the mean strongly downward.

Contraharmonic Mean
\[C = \frac{120^2+125^2+0^2+130^2+122^2}{497}\] \[= \frac{60489}{497} \approx \color{green}{121.7}\]

Advantage: Robust against small values (pepper noise). Result closer to actual pixel values.

Application in Image Processing

The contraharmonic mean is used in image processing as a contraharmonic mean filter. It is particularly effective against pepper noise (black pixels in bright areas) because it suppresses small values and favors larger values. This leads to better results than the arithmetic mean, which is strongly influenced by outliers.

Mathematical Foundations of Contraharmonic Mean

The contraharmonic mean is an important measure of position with special properties, which is significant in signal processing and statistical estimation theory.

Properties of Contraharmonic Mean

The contraharmonic mean has characteristic mathematical properties:

  • Inequality: C ≥ A ≥ G ≥ H (largest of classical means)
  • Complementary: H · C = A² (product of harmonic and contraharmonic = square of arithmetic)
  • Weighting: Strongly favors larger values, suppresses small values
  • Square-Based: Uses squares of values in numerator
  • Lehénian Means: Special case for r = 1: M₁ = C

Relationship to Other Means

Complementarity to Harmonic Mean

The most important relationship is: H · C = A²
The contraharmonic mean is complementary to the harmonic mean. If H is small (dominated by small values), C is large (dominated by large values).

Order of Means

H ≤ G ≤ A ≤ C
The contraharmonic mean is always the largest. Equality holds only when all values are identical. The difference increases with greater dispersion.

Application in Image Processing

Contraharmonic Mean Filter

The contraharmonic mean filter is a nonlinear filter for noise suppression:

  • Pepper Noise: Black pixels (small values) → C favors large values and suppresses pepper noise
  • Salt Noise: White pixels (large values) → Harmonic mean is better (favors small values)
  • Parameter Q: Extended form with exponent Q: C_Q = Σ(x^(Q+1)) / Σ(x^Q)
  • Q > 0: Eliminates pepper noise; Q < 0: Eliminates salt noise; Q = 0: Arithmetic mean

Generalization: Lehénian Means

Definition

The contraharmonic mean is a special case of Lehénian means (Power means): M_r = (Σx^(r+1) / Σx^r)^(1/1) for r = 1

Other Special Cases
  • r = -1: Harmonic mean
  • r = 0: Geometric mean (limit)
  • r = 1: Contraharmonic mean
  • r → ∞: Maximum

Practical Considerations

When to Use Contraharmonic?
  • Pepper Noise: Eliminate black pixels in images
  • Small Outliers: Robustness against small values
  • Large Values Important: When larger values should have more weight
  • Complementary Analysis: Together with harmonic mean
Be Careful With
  • Large Outliers: C is strongly influenced by large values
  • Salt Noise: For white pixels, harmonic mean is better
  • Zero Values: Zero in denominator possible if all values are zero
  • Interpretation: Less intuitive than arithmetic mean
Summary

The contraharmonic mean is a specialized measure of position that strongly favors larger values and suppresses small values. It is complementary to the harmonic mean with the relationship H · C = A². Its main application is in image processing for elimination of pepper noise (black pixels). As part of Lehénian means, it offers together with the harmonic mean a complete view of data distribution. While the harmonic mean emphasizes small values, the contraharmonic mean highlights large values – this complementarity makes both means together very valuable for robust data analysis.