필터 지우기
필터 지우기

How can I determine the expected sum of randomly chosen numbers from vector? (combinatorics)

조회 수: 1 (최근 30일)
Hello there,
I would like to solve the following problem with Matlab.
If you choose two numbers out of this vector [-1 -1 -1 1], what is their sum, on average?
With nchoosek(4,2) I can determine that there are 6 combinations, but how can I iterate through these combinations to determine each of the 6 sums?
Thanks,
Tobias

채택된 답변

Joost
Joost 2020년 4월 26일
The nchoosek function can give you all combinations of 2 elements from the vector.
Instead of nchoosek(4, 2), use nchoosek([-1 -1, -1, 1], 2)
I am not sure how it deals with replicas.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Elementary Math에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by