Problem 43494. Weighted Convolution
Given two input vectors x = [x_1, x_2, ..., x_K] and y = [y_1, y_2, ..., y_K] of equal length, compute the weighted convolution output z = [z_1, z_2, ..., z_K], where
z_k = sum(nchoosek(k1,j1)*x_{kj+1}*y_j, j = 1..k), k = 1, 2, ..., K
Example: x = [1, 2, 3]; y = [4, 5, 6]. Then z = [z_1, z_2, z_3] where
z_1 = nchoosek(0,0)*1*4 = 4 z_2 = nchoosek(1,0)*2*4 + nchoosek(1,1)*1*5 = 13 z_3 = nchoosek(2,0)*3*4 + nchoosek(2,1)*2*5 + nchoosek(2,2)*1*6 = 38
Hint: This can be seen as the linear convolution weighted by the binomial coefficient. It is straightforward to solve this problem using a for loop. I am wondering if there exists some more elegant way (e.g., vectorization) to do this.
Solution Stats
Problem Comments

7 Comments
Liked because 1) It's not spam and 2) You use my "better way to do this?" tag for the same reason I do.
I also dislike the recent trend of spoiling Cody with trivial problems. Some people, especially those top 4 players on the Triathlon scoreboard, have generated too many trivial problems, in the hope of wining the Triathlon prizes (related to MATLAB central's 15 years celebration). This shameful behavior damaged not just the Triathlon competition, but also our Cody platform.
I understand better now why Cody becomes so boring. Thank you for the explanations.
We have increased the score required to create a problem. So this should not happen anymore.
Hi Aditya, Could you take a look at this problem: http://nl.mathworks.com/matlabcentral/cody/problems/431172dindexes? Every time I click the "Solve" button, my internet browser cannot be directed to the right page.
I figured out what 's wrong there. The correct link is www.mathworks.com/ ..., not nl.mathworks.com/...
Awesome.
Solution Comments
Show commentsProblem Recent Solvers32
Suggested Problems

The Hitchhiker's Guide to MATLAB
3293 Solvers

244 Solvers

Pernicious Anniversary Problem
820 Solvers

9420 Solvers

1504 Solvers
More from this Author29
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!