# Is there a name for the number of ones in a binary vector?

I'm creating two types of binary vector. The vectors have $$M$$ components and either $$N$$ ones or $$(M-N)$$ ones.

If you were to take all permutations of these vector types there would be a symmetry in the sets. One set could become the other by swapping the ones for zeroes and the zeroes for ones. For example, you could have the pair:

\begin{align}v &= [1, 0, 0, 1, 0, 1, 1] \\[10pt]v' &= [0, 1, 1, 0, 1, 0, 0]\end{align}

It feels like there should be a name for this type of a symmetry, and a name for the number of ones or conversely zeroes in the vector. But I can't think of what to search to find out what that name is. For the moment I'm using depth, but that doesn't seem right.

Is there a name for the number of ones in a binary vector, and a name for the symmetry between it and its logical inverse?

Potentially related:

1. Question on permutation depths. The answer to this questions suggests n-tuples as the correct name.

## Edit:

Suggestion:

As there doesn't appear to be a term that fully captures this idea, I suggest one of the following:

• Symmetric combination depth,
• Symmetric permutation depth,
• Symmetric depth,
• Symmetric hamming weight,
• Symmetric cardinality
• I'm not sure if there are official terms for either of these contexts. From a CS background the bit flipping would be called the "two's complement" relationship and is used for negating numbers, so perhaps you could call this just simply negation. As for the number of ones in the vector, I would call it the sum, or the weight. Mar 18 at 21:52
• We have questions about calculating this on SO, eg stackoverflow.com/q/109023/4014959 Mar 19 at 7:47
• @PavanC. - Not quite. To negate a number in two's complement, you flip the bits, and then add $1$. Mar 19 at 8:04
• @PavanC. Just inverting the bits is used in ones' complement. Mar 20 at 6:51

There is the term Hamming weight: https://en.wikipedia.org/wiki/Hamming_weight

• Thank you! Is there a name for the logical inverse of the hamming weight? Or a name for the two things together? Mar 18 at 22:05
• Very commonly referred to, at least in computer science, as 'zero norm' (despite not being a norm). It gives rise to a valid distance, the Hamming distance
– Oly
Mar 19 at 10:58

For binary vectors like you have, it's called "population count", Many programming languages have a popcount( ) function (C++), and some microprocessors even have popcnt available as a single instruction (x86).

This is also mentioned as a special case in the Hamming weight article that @Maksim's answer refers to.

Reply to comment: I'm not sure what you mean by "apply to both sides of the symmetry". If it helps, popcount only counts the number of $$1$$s, not the number of $$0$$s. If you want the number of zeros, you could let $$\operatorname{not}()$$ be "bitwise not", and then $$\operatorname{zeros}(v) = \operatorname{popcount}( \operatorname{not}(v))$$

If you want to know how to describe the symmetry, you could say "$$\operatorname{not}( )$$ provides a bijection between $$\{v \mid \operatorname{popcount}(v) = N\}$$ and $$\{v \mid \operatorname{popcount}(v) =M-N\}$$.

• Does this apply to both sides of the symmetry? Mar 19 at 10:01

### The weight

If the vectors are guaranteed to contain only zero or one, the count of ones is equivalent to the variously-named L1/taxicab/Manhattan norm, all of which are commonly-used terms in computer science and some areas of mathematics. (If we can't guarantee ones or zeros, we have the Hamming weight as described in another answer).

### The inverse

The inverted vector you describe is called the one's complement or bitwise NOT, each of which is a commonly used term in computer science.

You can call it the cardinality (or size) of the support. It's typically associated with real-valued functions, but since zero and one are real values, treating this as a special case doesn't sound unreasonable to me. Support itself is a conveniently concise term, but would refer to the positions which are nonzero, not just the count.

For example, assuming one-based indexing your $$v=[1,0,0,1,0,1,1]$$ has support $$S=\{1,4,6,7\}$$ since $$v_i\neq 0$$ for $$i\in S$$ and the size of that support is $$\lvert S\rvert=4$$.

• What does "the positions that are nonzero" mean in this case? Wouldn't that mean the only zero position is $v = [0, 0, 0, ..., 0]$? Mar 18 at 22:07
• @Connor I've added an example, hope that helps.
– MvG
Mar 18 at 22:15