Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Kindly see the attached code. I would like to generate 10 samples of size 5. Then calculate the mean of each sample, so that I have 10 means. However, my data contains only five elements. Obviously, something is wrong. Kindly assist.
Solved! Go to Solution.
1) A program will return the last value, so in your case the last calculated y (for k=n). So you have to collect all values in a vector (using the vector index at y). And the last statement in the program must be "y" (or "return y") so that the whole vector is returned.
2) When you sum the elements of b you have to apply the index i if you use it on the sum. Otherwise the sum returns n-times the whole vector b and y will end up being the very same as vector b.
A bit easier (sum of a vector)
Even easier using the built-in "mean" function
And at last a tricky one using the "matrix" function
1) A program will return the last value, so in your case the last calculated y (for k=n). So you have to collect all values in a vector (using the vector index at y). And the last statement in the program must be "y" (or "return y") so that the whole vector is returned.
2) When you sum the elements of b you have to apply the index i if you use it on the sum. Otherwise the sum returns n-times the whole vector b and y will end up being the very same as vector b.
A bit easier (sum of a vector)
Even easier using the built-in "mean" function
And at last a tricky one using the "matrix" function
Thank you so much, Werner. I appreciate it.