Skip to content
DeepForgeby svx
All problems
EasyLinear Algebrala-245

Feature Map Dimension Count

Problem

Return the dimension of the polynomial feature map of degree at most d in n variables.

It equals the number of monomials of total degree <= d, which is the binomial coefficient C(n + d, d).

Hint

This is the stars and bars count of monomials with total degree at most d.

Test cases

case 1
in: [2,1]
expected: 3
case 2
in: [2,2]
expected: 6
case 3
in: [3,2]
expected: 10
case 4
in: [1,5]
expected: 6
Starter codePython
def feature_map_dimension(n, d):
    # Your code here
    pass

4 test cases · run your code against them in the editor