What kind of mathematical order is this?

  • Context: Undergrad 
  • Thread starter Thread starter matthew180
  • Start date Start date
  • Tags Tags
    Mathematical
Click For Summary

Discussion Overview

The discussion revolves around understanding the mathematical properties of counting "1" bits in a 16-bit value, specifically exploring the distribution of these counts and seeking a mathematical formula to replace a brute force approach. The inquiry touches on concepts related to combinatorics and the Hamming weight.

Discussion Character

  • Exploratory
  • Technical explanation
  • Conceptual clarification

Main Points Raised

  • Matthew describes a brute force program that counts the number of "1" bits in 16-bit values and seeks a mathematical understanding of the results.
  • Matthew initially speculates that the distribution of counts might be logarithmic or related to sine/cosine functions based on the observed rise and decline in values.
  • Another participant points out that the results correspond to Hamming weights, linking to the concept of counting the number of ways to select bits.
  • A participant confirms that the k-th entry in the table represents the number of ways to select k bits out of 16 to be "1".
  • Matthew acknowledges the term "population count" as another descriptor for the concept being discussed.

Areas of Agreement / Disagreement

Participants generally agree on the identification of the concept as related to Hamming weights and population counts, but there is no consensus on the initial interpretation of the distribution's mathematical nature.

Contextual Notes

The discussion does not resolve the initial assumptions about the mathematical nature of the distribution, nor does it clarify the implications of the Hamming weight in this context.

matthew180
Messages
2
Reaction score
0
What kind of mathematical "order" is this?

Disclaimer: Sorry if this question is off-topic, I really don't yet know where it "belongs".

I wrote a program that counts the number of "1" bits in a 16-bit value. My program is brute force right now (loop 0 to 65535, shift each number and count the bits), but I would like to understand the results and how this problem could be solved mathematically, i.e. with a formula vs brute force. Since any integer in the range 0 to 65535 will go into 1 of 17 "buckets", how can I make the determination without shifting and counting the bits?

Initially I thought the results were logarithmic, but the values rise and decline, so now I'm thinking they are more related to sine or cosine. Here are the results, can anyone explain to me the relationship I am looking at here?

Thanks,
Matthew

1 numbers had 0 1's
16 numbers had 1 1's
120 numbers had 2 1's
560 numbers had 3 1's
1820 numbers had 4 1's
4368 numbers had 5 1's
8008 numbers had 6 1's
11440 numbers had 7 1's
12870 numbers had 8 1's
11440 numbers had 9 1's
8008 numbers had 10 1's
4368 numbers had 11 1's
1820 numbers had 12 1's
560 numbers had 13 1's
120 numbers had 14 1's
16 numbers had 15 1's
1 numbers had 16 1's
 
Physics news on Phys.org


The k-th entry (0-up counting) in your table counts the number of ways you can select k bits out of 16 to be a 1 (and the rest 0), right?
 


@jedishrfu: Thanks! Population count, I should have realized that.

@Hurkyl: Yes, that seems to be another way to describe the idea.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
967
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 13 ·
Replies
13
Views
2K
  • · Replies 7 ·
Replies
7
Views
3K
  • · Replies 55 ·
2
Replies
55
Views
7K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K