Hello everyone,
Why is the mean function not giving me the average of my data? Am I doing it wrong?
You should attach the Prime worksheet!
Guess:
If your z is a range (not an vector, there's a distinct difference between a range and a vector!), and Tclad is a function, then its result is also a range, and you cannot use mean() to calculate the average of a range.
Success!
Luc
Hi,
you are right!
The new Prime 11 vec function can help out in these cases.
Stuart
You sure should have attached your worksheet and also said which version of Prime you are using.
As others already suspected i also think that you had defined you variable "z" as a range and not as a vector.
That way Tclad(z) is not a vector, too. Actually its kind of an invalid object which you can see if you try to assign it a variable. TC:=Tclad(z) will throw an error message. The "mean" function as you noticed is applied to every single result and not to a vector consisting of all of them.
Solution to your problem is to use a vector "z" instead of a range "z". How to achieve that depends on the version of Prime you are using.
Best way may be to define "z" right ahead from the start as a vector, but we can't say for sure as we do not see your worksheet and there is a (I think negligible) possibility that you need “z” as a range somewhere else. If you are using Prime 11 you can use the new function "vec" to do so.
As an alternative you can use your existing range variable and convert it to a vector. The new "vec" function is able to do this as well.
In case you are using a version of Prime prior to version 11 you have basically two options to convert a range into a vector.
You can use an undocumented trick which will not work in newer Prime versions or you use a user-defined function which does the job of converting a range to a vector. A simple one is shown below.
Once you use a vector instead of a range you can assign the function results to a variable and also mean will work as you expected
The attached sheet is in P11 version. If you use an older version of Prime you will have to use the pictures and retype.
EDIT: As @StuartBruff correctly noted below the first version of this answer of mine was erroneous as I falsely wrote that the undocumented trick would work in P10. Actually it doesn't and because the new function "vec" is not yet available in P10 you have to resort to a user-defined function for turning the range into a vector. You may also use a different user-function to create a vector right ahead - examples were posted in the forum a couple of times.
Screenshot an attached file were replaced and are correct now (hopefully 😉 )
Are you sure the Prime range-to-vector undocumented trick works in Prime 10? I thought the prime(!) driver for getting vec in Prime 11 was that the method was "fixed" in Prime 10?
(From Mathcad Prime 10)
Stuart
@StuartBruff wrote:
Are you sure the Prime range-to-vector undocumented trick works in Prime 10? I thought the prime(!) driver for getting vec in Prime 11 was that the method was "fixed" in Prime 10?
Damned! Of course it does not work in Prime 10. You are absolutely correct that Prime 10 is the version where the trick does not work no longer but the official way in form of function "vec" is not yet available.
So in Prime 10 (and I think @MA_13282691 is actually using P10) the way to go is either defining his "z" as a vector right ahead (function doing so have been posted here ion the forum,too, from time to time) or using a user-defined function for converting a range to a vector.
To avoid confusion I'll edit my answer above and the file attached.
Thanks for being attentive!
No worries, Werner.
I only remembered because I'd been playing with the vec function and knew there was a PTC document giving the MP10 workaround Range2Vec function.
Stuart
