cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

average value

YA_10963798
14-Alexandrite

average value

Good evening everyone,

 

I have 43 level and in each level I have 16 elements ... I want mathcad to calculate the average value in each level >> summing the 16 elements in each level and dividing them by their number (16). 

but what I get is the opposite ... it sums all the  levels (43) and divides them by 43... 

YA_10963798_0-1733675801926.png

 

YA_10963798_0-1733669487511.png

I expect the answer to contains 43 value not 16 

I tried to use programing ..I get worse result 

YA_10963798_1-1733669594798.png

I also, tried to use a simple mathcad sheet to post .. it works there , but not at my original sheet ;(

YA_10963798_2-1733669988440.png

 

I posted both the original and the simplified version for your assessment

Thanks in advance 

 

 

ACCEPTED SOLUTION

Accepted Solutions
StuartBruff
23-Emerald III
(To:YA_10963798)

I think this does what you want for the average.

 

2024 12 08 A.png

 

However, I'm wondering whether your calculated value Rc;cal;C;CPT;min is what you want, as that only has 16 values (ie, is the minimum of the 43 layers for each of the 16 "element" vectors)?

 

Stuart 

View solution in original post

11 REPLIES 11
YA_10963798
14-Alexandrite
(To:YA_10963798)

I tried also this >> 

YA_10963798_0-1733681157941.png

so to clarify more ... The R is a nested  which are the results of 16 elements (CPT) 

YA_10963798_1-1733681374470.png

the number 43 represents the level of each R 

I want to calculate the average value of R in each level .... the function has to calculate average of  the Rs of the 16 elements in each level 

YA_10963798_2-1733681754974.png

 

So the answer should be 43 vector 

StuartBruff
23-Emerald III
(To:YA_10963798)

I think this does what you want for the average.

 

2024 12 08 A.png

 

However, I'm wondering whether your calculated value Rc;cal;C;CPT;min is what you want, as that only has 16 values (ie, is the minimum of the 43 layers for each of the 16 "element" vectors)?

 

Stuart 

YA_10963798
14-Alexandrite
(To:StuartBruff)

Stuart>> Thank you so much that works for me 

It is been a while since we last chatted...I hope you are doing well

StuartBruff
23-Emerald III
(To:YA_10963798)


@YA_10963798 wrote:

Stuart>> Thank you so much that works for me 

It is been a while since we last chatted...I hope you are doing well


It has indeed been a while, Yusra.  I hope you are likewise doing well - and finding time to do other things on your weekend besides work!  Still, who am I to talk ... 🙂

 

Stuart

YA_10963798
14-Alexandrite
(To:StuartBruff)

for the minimum value I tried to use same concept ...it says it must be a vector

YA_10963798_0-1733683633995.png

 

StuartBruff
23-Emerald III
(To:YA_10963798)


@YA_10963798 wrote:

for the minimum value I tried to use same concept ...it says it must be a vector

YA_10963798_0-1733683633995.png

 


 

Yes.  That, unfortunately, is to be expected because the statistical functions do not vectorize.

 

2024 12 08 B.png

 

So, a different approach is needed. Fortunately, it is a simple one.

 

2024 12 08 C.png

 

Stuart

 

(I've redefined rows and cols at the beginning of your worksheet to avoid conflicts with the built-in functions of the same name.  I've also disabled the CWD definition because I don't have that folder, and I'm far too lazy to scroll back to the top of the worksheet to re-enable it.)

YA_10963798
14-Alexandrite
(To:StuartBruff)

Thank you so much Stuart that so thoroughly explained and solved

I appreciate your help 

ttokoro
20-Turquoise
(To:YA_10963798)

image.pngimage.pngimage.png

Werner_E
25-Diamond I
(To:ttokoro)

@ttokoro 

It looks to me that @YA_10963798  is maybe(?) rather looking for something like this:

 

Werner_E_0-1733705867758.png

 

Not sure if the result should be a nested vector as shown in the picture above or rather a simple 12x1 vector.

But in any case I would prefer a functional solution like @StuartBruff  had provided which is more generic and does not need to define any worksheet range variables.

 

@YA_10963798 

Guess that Stuart has already solved your problem. Next time you create a simplified sheet it would be a good idea to manually type in the complete result vector you would like to create. That way it would be much clearer what you are looking for and also it would be clear which data structure you would like to see the results to be arranged in (nested vector vs. simple vector).

BTW, I couldn't make a try with your original sheet because of the missing Excel data file (I finally cleaned up my workspace). I know you posted it in other threads earlier, but I was far too lazy to look around for it.
Like Stuart I fond it irritating that you defined "rows" and "cols" as variables. We often need to use the built-in functions of the same names when working in your sheet and its tedious to experience an error message every time we do because Prime assumes that we mean your variable and we have to manually re-label the name as being a "function" and not a "variable".
I strongly second Stuarts suggestion that you should rename those variables as he already has shown in the sheet he posted.

StuartBruff
23-Emerald III
(To:Werner_E)

Curses! Foiled again!

 

StuartBruff_0-1733705189340.jpeg

 

I was about to reply to Tetsuro's post, but I see you've beaten me to it.

 

Still, here's a range variable version ...

 

2024 12 09 A.png

 

And an implied version of TransposeNested that uses a matrix intermediary to do the transposition.     

 

2024 12 09 B.png

 

It's often a lot easier to work on a matrix than nested vectors.  And vice versa.  😇

 

Stuart

YA_10963798
14-Alexandrite
(To:Werner_E)

Hi Werner, 

I hope you are doing well... Thank you for your reply . 

I attached both  sheets because I felt it is maybe needed ... 

For the rows and cols ,,, To be Honset , Stuart has told me before and I fixed it in another sheet and haven't done it here as well.. I will fix that right away 

Announcements

Top Tags