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

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

Mean of array problem

Raiko
16-Pearl

Mean of array problem

Hello folks,

I'm facing a frustrating problem as, to me, my approach appears straight forward and therefore watertight. It is as follows:

  1. I've got some measurement data from which I'd like to exclude the initial measurement points as they merely show the start up of a process and I'm interested in the established process (the velocity of air in a wind tunnel in my case)
  2. I extract a subset of measurement points by giving a start and stop value for the data.
  3. A range variable is defined by these start and stop values. This way I'm able to control the extraction and the visualisation in a XY plot.
  4. I calculate the mean of this subset.
  5. An array is defined that contains in each element the mean value. This is done to visualise the mean in relation to the data points
  6. Both sets are displayed in a XY plot with i as tzhe range variable

As apparent in the attached file, the range doesn't work for both. One array display (VA) appears to stop at the index of its own array (at 100) instead at the index as defined by i (145). Moreover, the average is biased.

Weird!?

The way I see it, the subset VA and the average array mVA should start and stop at the same index. Perhaps this is the culprit. Does anybody have an idea?

Thanks in advance for any help

Raiko

13 REPLIES 13

Several things are happening here.

first off, your variable mVA doesn't need to be an array--the mean of an array is a single number. Mathcad is perfectly happy plotting a single number against a range variable. (Try it!)

Second, the reason your mean value seems skewed is because there are a large number of values clustered at the low end. (histogram is a great function for seeing the way data is distributed. Researching this problem led me to discover another problem:

you define x0 and x1 as the trim points for your data--that's a good idea, it lets you change your trims without risking altering the submatrix function call. But when you get below the submatrix function VA is an array that starts at index 0. So when you plot VA[i against i, you're discarding the front 46 points of VA.

I plotted Y<0> against Y<1> (second column against first). Your data shifts at about index 85. When I made x0 = 85, the mean value got healthy, but the circles dissappeared from the plot. Why? Because VA is now 145-85 = 60 elements long, so VA[85 doesn't exist.

I've done some mods, made some notes. Good Luck!

Thank you Fred!

one problem is that each array starts at ist own index, which I managed to overecome by using my start and stop values on the diagram so that the measurement data and the mean begin at the same point.

And thank you for your helpful hints as well!

Raiko

MikeArmstrong
5-Regular Member
(To:Raiko)

You could use the "Subvector function" to extract your data.

See attached image.

Mike

RichardJ
19-Tanzanite
(To:Raiko)

Your problem occurs because array indicies always start at the value of ORIGIN, which by default is 0. That is true regardless of whether or not you specifically assign values to all the elements when you create the array, or whether the array was created from a larger array using submatrix.

...

MCADunk_4.gif

...

Hello Jean,

for the life of me - I don't get it. I haven't changed anything, simply shut off my computer over night and this morning: Hogwarts!

Yesterday, there was an offset which I couldn't fix. However, this morning, upon opening the MC document everything was as it should be. Both point series (data and averages) started at the same point. Is this a MC glitch or some windows bug?

Anyway, folks. Thank you for your time

Raiko

Raiko,

My interpretation was that you wanted to plot the mean all along the X at every of the indices. That's only how to plot it. Thus you will have the data around the mean as an artificial Cartesian X. You can have it as a continuous line or points. The bar plot is supplementary and superfluous information.

Jean

Hello Jean,

almost correct.

I wanted to display the average value as a line along with the data points in a cartesian graph. For this I extracted a subset of data points from the original data, since I din't need the start up values of the wind tunnel.

I chose, say, data starting at point 55 and cut off at, say, 155. The new data arry started its index at 0 whereas the calculated average began its display in the graph at 55. Hence, the two data sets started at different points in the graph.

I fixed this, by adding the start value of 55 to the new data arrays index. Therefore, they started at the same point on the graph.

x:=(55,155)

newdata:=submatrix(data,xo,x1,0,0)

average:=mean(newdata)

i:=0..last(newdata)

In the graph I did:

newdata(i+xo) over i

and

average over i

Thanks for your input

Raiko

MikeArmstrong
5-Regular Member
(To:Raiko)

Raiko,

Why don't you post your worksheet, so it is clear to the members who tried to help, what you where after.

Mike

Mike,

you can find a worksheet (MC 11) at the very first posting of this post

Raiko

MikeArmstrong
5-Regular Member
(To:Raiko)

Raiko Milanovic wrote:

Mike,

you can find a worksheet (MC 11) at the very first posting of this post

Raiko

Raiko,

I meant your completed project.

Mike

Mike,

I'm sorry but I'm afraid I can't do that 😉 And as I said, over night, by some miracolous quirk perhaps, everything turned out to work right.

Raiko

P.S.

Forgot to attach the new worksheet. Mea culpa

MikeArmstrong
5-Regular Member
(To:Raiko)

Raiko Milanovic wrote:

Mike,

I'm afraid I can't do that. And as I said, over night, by some miracolous quirk perhaps, everything turned out to work right.

Raiko

Raiko,

If your is work is confidential you can always post an image of the solution, just to give an idea of what you where trying to achieve. Otherwise, what is the point of forum members taking their time to help when they don't have the solution at the end.

This thread will become worthless to new forum members trying to understand Mathcad if there is no end solution.

Mike

Top Tags