1

I am aware of figuring out the number of non-negative integers which sum to a certain number.

Number of ways to write n as a sum of k nonnegative integers

I’ve seen mentions of partitions, “stars and bars”, etc.

In the context of a survey:

Let’s say we have 5 questions with likert scales which range from 1 to 6 for possible values.

Then let’s say I want to know all of the permutations to get the sum score of 20. Order matters because each question is getting at a specific/useful piece of information even when they are being added together into a sum/composite score.

I am wondering if there is already a generalized solution to this where you can easily change the number of questions, the range of values for each question, and the sum score of interest.

If there isn’t one, I am hoping to find out what would help lead me to find one/if one has to create a specific solution for each specific set of parameters (ie it doesn’t generalize well).

I also saw that this kind of problem can be considered related to the knapsack problem.

  • This isn't very clear. Are you asking for the number of $5$-tuples $\left(a_1, a_2, a_3, a_4, a_5\right) \in \left{1,2,3,4,5,6\right}^5$ with $a_1 + a_2 + a_3 + a_4 + a_5 = 20$ ? If so, I believe there are threads here that find an alternating-sum formula for such numbers using the Principle of Inclusion/Exclusion. – darij grinberg May 01 '19 at 20:31
  • Yes that is what I’m asking and they are constructed based on the constraints I set. Apologies if that wasn’t clear. – primordial2 May 01 '19 at 20:34
  • @MikeEarnest Yes thanks! It looks like your answer will work! I’m self learning so I’m curious if you had any thoughts on the pros/cons of using your formulation vs the other one within the context of what I’m doing. – primordial2 May 01 '19 at 21:39
  • I think my formulation is easier to program, but the other would take less computation time. Whether or not the optimization is worth the effort depends on how big your numbers are; if there are lots of questions right in the survey, my method might take a long time to compute. – Mike Earnest May 02 '19 at 05:09
  • @MikeEarnest When you say “how big numbers” and “lots of questions right”, I assume you mean how many options on the likert scale (e.g. 5, 8, 11), and then how many questions are offered (e.g. 5, 10, 20) – primordial2 May 02 '19 at 10:31

0 Answers0