Vogel-Dobbener entropy - MATLAB Cody - MATLAB Central

Problem 44933. Vogel-Dobbener entropy

Difficulty:Rate

Vogel-Dobbener entropy is a measure of dispersion for ordinal variables.

Given an ordered list of distinct observations u_(1), ..., u_(k) with observed relative frequencies f_1, ..., f_k, the Vogel-Dobbener entropy is defined as

 VD = -(sum_{i=1}^{k-1} (F_i log2(F_i) + (1 - F_i) log2(1 - F_i))

where F_1, ... F_k are the cumulative relative frequences, i.e.

 F_i = sum_{j=1}^i f_i

The Vogel-Dobbener entropy of a sample satisfies 0 <= VD <= (k - 1); the normalized Vogel-Dobbener entropy is thus defined as

 VD* = VD / (k - 1)

For example, suppose that your sample is [2.7 3.3 2.0 3.3 1.7 3.7]. Then:

  • k = 5 (there are five distinct observations);
  • u_(1), ..., u_(k) = [1.7 2.0 2.7 3.3 3.7]; (note that 3.3 only appears once);
  • f_1, ..., f_k = [1/6 1/6 1/6 2/6 1/6];
  • F_1, ..., F_k = [1/6 2/6 3/6 5/6 6/6];
  • VD = 3.2183; (approx.)
  • VD* = 0.8046. (approx.)

Your task is to write a function that, given a list of observations (unordered and possibly containing duplicates) computes the normalized Vogel-Dobbener entropy VD* of the sample. Round to four decimal digits.

Hint: if all observations in the sample are the same, then k = 1, the sum in the definition of VD is empty, and VD equals zero.

Solution Stats

35.9% Correct | 64.1% Incorrect
Last Solution submitted on Nov 06, 2025

Problem Comments

Solution Comments

Show comments
Join Cody Contest 2025 — Have Fun and Win Prizes!
...
We’re excited to invite you to Cody Contest 2025! 🎉 Pick a team,...

Problem Recent Solvers12

Suggested Problems

More from this Author19

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!