Filtering and calculating averages of array subsets

I've got a 2-D array coming out of a loop and I need to calculate average for subsets corresponding to iterations 0-9, 10-19, etc..  Additionally, I need to filter out values above and below acceptable limits before calculating average.  Any suggestions for how to approach this?
Solved!
Go to Solution.

My suggestion is to slog through each array subset, use a for loop to add up the values you want, keep track of the number of values, then divide out for the average. 
Every tenth reading you could clear the sum and counts.
The results would be saved in an array that only adds a value every tenth loop.
You could keep track of the one to ten value separately from the number of values accepted ( a.k.a. Filtering).
So my slog suggestion would be a for loop, two counters ( # accepted values and one to ten count), an array to store the averages and a numeric to hold the sum.
The filter criteria would produce a Boolean that would toggle adding to the sum and adding to the # accepted values.
The Sum and the counters need to be shift registers, and as I mentioned, there would be some logic to clear these shift registers every time the 'one to ten' count got to ten
Mark Ramsdale

Similar Messages

  • Clear array and take average of values in array continuously

    I have a continuous signal that I am acquiring with hardware (sampling at 1000Hz).  I want to be able to insert the data into a 1D array for 5 seconds, and then take the average of these 5000 samples.  So basically, every 5 seconds I need to take the average of a 1D array and create a new array for the next 5000 samples.

    There is no reason to accumulate the data into an array if all you need is the average.
    Simply add the values into a shift register. Every 5000 points devide the sum by 5000, output the average, and zero the shift register for the next series of data..
    LabVIEW Champion . Do more with less code and in less time .

  • Average of a subset of data

    Post Author: squishy
    CA Forum: Formula
    I need to find a way to get the average of a subset of data
    in a report.
    For example
    The datasource returns:
    User        
    Month          Current       
    Bob           mar                10               
    Janet         mar                  5                 
    James        mar                 24               
    Bob           feb                12               
    Janet         feb                  4                
    James        feb                 22               
    Bob           Jan                14               
    Janet         Jan                  3                 
    James        Jan                 30            
    I need  the report to
    show in addition to the current value for march for each user, the average of
    the previous two months
    So the report would actually show:
    User        
    Month          Current        Average
    Bob           mar                10                13
    Janet         mar                  5                  3.5
    James        mar                 24                26
    Is there a way to get crystal to calculate the average for
    the previous two months for each user?

    Brad
    The calculations are for Emission calculations for vehicles.  The main input data set is a second-by-second file containing many channels / groups. For a number of the raw channels (eg distance) the raw data is first integrated and then analyzed into a series of windows
    oDistanceWindow(iLoop)  = ODistanceInt(iPos) - ODistanceInt(iLoop)
    Each window is defined by a start (iloop) and end index (ipos) referencing.Each result is then added to an output group.
    However my problem is I want  to calculate a statistical parameter for each of these sub-groups of data and generate an output group with these results. An example being the mean speed. This is not a good example since this can be calcuated easily by dividing the distance and time already being calculated.
    I hope this helps
    David

  • Difference between  aggregation and calculation tab in BEx Query Designer

    HI,
    I am using BEx Query Designer for my report, for the key figures in the coloumn area i slected one numeric key figures, in  the properties tab i found aggregation tab and calculation tab.
    I need to sum up the total values for that particualar coloumn, when i used calculation tab i found to sum all the values for a particular coloumn, then what is the use the aggreagation tab?
    I not able to used that Aggregation tab it is showing as a hidden fields...
    can any one tell me whats the exact difference between these tabs and when we need to use which tab?
    With Regards,
    Thanesh Kumar.

    Hi Thanesh Kumar,
    I moved this thread from forum Data Warehousing to Business Explorer since it is a query related question (as SDN moderator).
    I could explain to you the difference between these two tabs.
    For "calculation" tab, it changes the display of result and does not change the calculation logic.
    It means that, if this key figure is used further in formula, still the original number (without "calculation" tab setting)  is used for further formula calculation.
    For "aggregation" tab, it changes the real calculation logic.
    The system takes the setting as the aggregation rule for records.
    The most common aggregation rule is of course summation. If you set to e.g. Average here, the system does the
    Average instead of summation when aggregating records. And the Average value will be taken for calculation
    in further formulas or other calculations.
    For "aggregation" tab, you could only use it for CKF (calculated key figure) or formula and you could not use it for
    a basic key figure. That should be the reason why you see it greyed-out.
    Regards,
    Patricia

  • Standard and Moving Average Price in Material Master

    Hello,
    Can any one please tell the basic difference between Standard and Moving Average price? both the cases how the Material Price is calculated?
    And please provide the accounting entry's also.
    Thanks

    Dear S McIntosh,
    You may check URL below that explain the difference between MAP and Standard price.
    http://help.sap.com/saphelp_47x200/helpdata/EN/47/60ff0749f011d1894c0000e829fbbd/frameset.htm
    Regards,
    ian Wong

  • How to consider only values 0 when calculating Averages

    Hi,
    Currently, I am using Avg (table.column) function to caluclate averages. However, one of our user wants to only consider records that are >0 when calculating averages. For example if a result set as 10 records, and only 2 of them has values >0 then typically Avg function would caculate based on (sum of 10 records/10). But per our user's requirement, he wants to consider (sum of 2 records/2) and ignore the remaining 8.
    Can you please tell me how to do achieve this?

    I found the solution after much deliberatiion myself :-). I used the following formula instead of the AVG function and it worked.
    Note that "Fact - +fact name+".column is a numeric column and can have null values.
    SUM(IFNULL("Fact - +fact name+".column, 0)) / COUNT("Fact - +fact name+".column)

  • Calculating Average then using it in another calculation.

    Hi,
    I would be grateful if someone could point me in the right direction - as I'm clearly being daft!
    I have a report that summaries the  SalesValue measure (which is an aggregate function in the universe)
    Week 1          £1000
    Week 2          £1500
    Week 3          £900
    I have created a variable TOTAL SALES (sum(salesvalue)) which successfully displays £3400.
    I have created a variable for average (Total Sales /3) which displays £1133.33.
    What is the best way to  create a variable for each week to show the difference between the average (£1133) and the sales for the week i.e Week 1 = +133, week 2=+367, week 3 =-233.
    Whenever I create this variable (SalesValue-Average) and put it next to week it doesn't calculate based in the total sales (£3400)
    I'm sorry if this is one of those easy simple things but I am new to WEBI and I'm struggling.
    Many thanks in advance.
    Jude

    Hi Jude,
    Prashant gave a good suggestion, you need to use calculation contexts.
    PS: If you are new you would benefit from the official guides, especially Using Functions Formulas and Calculations that can be found at https://help.sap.com/boall_en
    There are also tutorials Official Product Tutorials – SAP BusinessObjects Web Intelligence
    Thanks
    Simone

  • Condition class and calculation type missing for conditions downloaded from

    Hi All,
      I have downloaded all the condition types from R/3 using dnl custcndall
    I have even downloaded the following using r3as
    dnl_cust_cnd
    dnl_cust_prc
    dnl_cust_price
    But I have noticed that for the downloaded condition types, condition class and calculation types are missing. Please suggest.

    I have faced the same issue recently.
    The solution is in adapter object DNL_CUST_CNDALL for table T685 and other tables for T685 in that objet put the filters for condition type
    for ex: KSCHL eq PR00
    This sure will work.
    But you have to set this filter for all tables T685*
    Thanks
    Sarabjeet

  • How come the output of the Array Subset VI is 2-D when I specify a 1-D subset?

    1. I'm trying to strip off a row from a 2-D array so I can search for a match within that row. When I use Array Subset and specify one row as the subset (for example, Row Index=0, Row Length=1, Column Index=0, Column Length=(a variable, typically 255), the output is a 2-D array.
    2. Do I have to use Reshape Array on the output of Array Subset to get the desired 1-D array? The help popup says I have have to add m dimension sizes to have the output be an m-dimensional array. If I add a dimension size, I get a 2-D output. If I fall back to one dimension size and hardwire it to '1', I get a 1-D array wire type but apparently the array doesn't contain all the data in the row from the original 2-D array.
    I'm using LV 5.1. What is the easiest way to strip off a row from a 2-D array in LV 5.1?
    I appreciate any help you can provide.
    Thanks,
    Jeff Bledsoe
    Jeffrey Bledsoe
    Electrical Engineer

    JeffreyP wrote:
    What is the easiest way to strip off a row from a 2-D array in LV 5.1?
    The easiest way to has always been just to use the "Index Array" function, choosing the indice of the row you wanted and with nothing wired to the column terminal (the lower one).
    Edit: I'm assuming that by "strip off" you mean "access", not "strip out"/"remove".Message Edited by Donald on 05-13-2005 02:03 PM
    =====================================================
    Fading out. " ... J. Arthur Rank on gong."
    Attachments:
    Index Out Row.jpg ‏6 KB

  • Array subset uses twice as much memory

    I have been chasing a problem with running out of memory when manipulating large ammounts of acquired data.
    My attached vi exhibits some very strange behavior.
    My original code used "Array Subset" to clear the data in a shift register.
    My revised code just uses an empty constant.
    Question #1. Why should it take at least double (perhaps triple) the ammount of memory to store data using the Array subset method.
    and.. Why is the memory allocated before the "Array subset" is used.
    Question #2. Why am I seeing significant residual memory usage that is not being re-allocated
    Labview Version 9.0.1 (32-bit)
    iTm - Senior Systems Engineer
    uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
    Attachments:
    Strange memory Allocation.vi ‏21 KB
    memusage.PNG ‏17 KB

    OK,
    The origins of this discovery was unexpected memory "behavior" in an application containing in excess of 1250 vi's and is attached to NI-DAq's, CAN and GPIB based hardware.
    We were storing 6 minutes of 50 channels sampled at 5khz and recived an out of memory error.
    To stop it failing, we reduced the sample rate to 1khz and gathered some metrics
    We did the calculatons on how much memory it should take to store this many samples (360x50x1000x8) = 144 meg
    The memory profiler was showing that on first run the memory would rise to an additional 432 meg at the end of sampling and at the point where the shift register was "zeroed" it would drop back to only 144 meg. On the next run it would rise back to 432Meg again.
    For intellectual property and simplicity reasons, I wrote a basic VI to demonstrate the problem we found.  I was not expecting it to be critqued for programming methods or whether or not it was a valid application.
    The Fundamental problem is that Labview should not allocate 3 times the memory required and not give back a third of it on completion.  Debug or otherwise.
    The condensed .vi was first written without the diagram disable, which was added later as a tool to aid peers and NI LV Guru's a way to easily see the problem.
    On another note, Why doesn't Labview access virtual memory to store this data instead of using RAM and running out?
    We are planning a code extetion to sream the data to TDMS to compensate for this "characteristic".
    iTm - Senior Systems Engineer
    uses: LABVIEW 2012 SP1 x86 on Windows 7 x64. cFP, cRIO, PXI-RT
    Attachments:
    Lost Memory.PNG ‏69 KB

  • Average of array elements

    Hi, I have a VI that's acquire data from Compact Field Point. These data come from cFP like an array. But I need acquire these data three times and, so, average them. There's a way to do this or I will have to use the "Index Array" function to separate each element of array and, so, make the average of each one?
    Any help will be appreciated

    It is not entirely clear to me what the array from the cFP contains (I have not used cFP). I see several possible scenarios:
    1) The array is a 1D array consisting of a single reading taken from multiple channels
    - In this case I am assuming that you want to average three of these data points. If this is the case then all you need to do is add the arrays together and divide by three.
    2) The arrayis a 1D array consisting of multiple readings from the same channel
    In this case I am assuming that you want to average all of the data from each of these sets then you can use a build array function to put make the three arrays into a single array, use the Sum function to add all of the array elements together, and then divide by the length of the array.
    3) The array is a 2D array
    In this case then you're receiving multiple readings from multiple channels. Since this solution is more difficult and I need more information to accurately answer your question I'll defer this solution unless needed.

  • Standarad price and moving average price

    What is the diff between Standarad price and moving average price ???
    Somasundaram

    Price Control V or S in material type
    When is it useful to use the price control V or S in Material Master ? 
    Do I have to follow the SAP standard setting in the material type for the following material types:
    - ROH(Raw materials) -> moving average price
    - HALB(Semifinished products) -> standard price
    - FERT(Finished products) -> standard price
    In which case and why is useful to change these standard setting in material type?
    What is difference between standard price and moving average price? 
    When and how to use it?
    Standard price are used for products that do not fluctuated frequently.  It is usually used for finished or semi finished products.
    Moving average price are used mainly for raw materials that are purchased externally.  The advantage of using moving average price for your raw materials is that your inventory costs will always reflect the current market cost.
    SAP strongly recommends that you do not select price control V for semi-finished products and finished products, because doing so will very easily cause the calculation of unrealistic valuation prices. SAP recommends: 
    Price control V for raw materials and trading goods; price control S for semi-finished products and products.
    If you nevertheless select price control V, take care in the following situations:
    1. Unrealistic prices occur if materials are produced and also retire during one period (that is, the inventory at the end of the period is smaller than the total of aquisitions from production orders) and if, in addition, several production orders belonging to a material were finished in this period, and the production order settlement calculates variances at the end of the period. Every single production order carries out an inventory coverage check and may therefore cause the moving average price to be changed. However, the individual production orders do not check whether the inventory available at the end of the period has already been debited by another production order. 
    Example: on 20 workdays in the period, 1 piece of material xyz was produced for each day and delivered to the warehouse at a price of USD 1000. At the end of the period there is 1 piece at the warehouse. Since an activity price of a participating cost center was higher than planned , every single production order calculates cost of goods manufactured of USD 1100 during the settlement. Every single one carries out a inventory coverage check and finds out that the variance can be posted completely to the inventory. That is, the ending inventory of one piece is debited with USD 20 x 100 and it consequently receives a price of USD 3000. 
    1. A settlement is carried out although not all costs have yet been posted to the order. This can even result in a price of 0 for the delivered product.
    2. No period check of the costs is carried out on the order, that is, costs from previous periods may be settled.
    3. Settling orders is already possible in the 'Delivery completed' status.
    Solution: Standard price for products together with possible manual price changes.
    If you are required to valuate semi-finished and finished products with actual prices that correspond to the costs of the actual production, SAP recommends you use the function of the material ledger for this. Here, a periodic actual price is created that is calculated on a much more reliable basis than the moving average price. A so-called price limiter quantity is used which makes sure that in the above example price differences are proportionally taken into account (95% of the total price differences) when valuating the 19 pieces withdrawn from material xyz which results in a periodic actual price of 1100 USD. In addition, it is possible as of Release 4.5 to even take into account the variances of the actual prices of the raw materials in the valuation of the semi-finished and finished products that are manufactured from it. 
    If we select std price for any type of material or mav and then make po, it will pick from material master or what?
    The Purchase Info Record have the FIRST priority.  When no po info record is found, the Purchase Order will pick the user LAST enter price.  The PO module do not pick up any price from material master.
    Regards,
    Ashok

  • Difference between Standard Pricing and Moving Average Price

    Hi,
    Would like to seek some advises on the difference between standard price and Moving average price.
    also, how does it affect the account postings differently?
    Thanks

    Standard Price
    Materials whose price control indicator is set to S are valuated in Financial Accounting (FI) at standard price.
    This is recommended for semifinished products and finished products.
    The moving average price is shown as a statistical value in the material master record.
    The standard price is normally calculated using a standard cost estimate for the material. The standard price can also be calculated in a mixed cost estimate.
    Moving Average Price
    When materials whose price control indicator is set to V are received from in-house manufacturing processes, they are initially valuated with a value you defined (such as the standard price). When you settle, the material stock account is debited with the variances. This results in a new moving average price.
    Valuating semifinished products and finished products with the moving average price is not recommended.
    Regards,
    Indranil

  • How to declare and initialize a STRING ARRAY (assign strings to array elements)

    How to declare and initialize a STRING ARRAY (assign desired strings to elements of an array, for example "abc", "def", "ghi", "jkl", etc.) in LabVIEW? I saw a "string array" block in help, but could not find it in the function palette. Does a spreadsheet string have to be in a file (or can it be in a string constant block)? Thank you.

    Hi,
    you can do it in several ways:
    1. Direct way: Create string array control on front panel and type strings in its elements
    2. Programmatically 1: Create string array indicator (or local variable of control), right click on it in block diagram, select "Create constant" from drop down menu. The array constant will appear. Now type values in this constant's strings
    3. Programmatically 1: Use "Build array", "Replace array subset", "Insert into array" or "Initialize array" functions from "Functions->Array" palette.
    And of course you can combine all of these methods.
    Good luck.
    Oleg Chutko.

  • Microsoft`s definition of 「All Instance」 for calculating average percentage of CPU usage is a mystery for me !!!.

    Hi, I was looking up in the 「How to Auto Scale」 document
      http://azure.microsoft.com/en-us/documentation/articles/cloud-services-how-to-scale/
    and got stuck in the below paragraph, the part that describes how to calculate the
     average percentage of CPU usage. 
    ==========
    All instances are included when calculating the average percentage of CPU usage and the average is
    based on use over the previous hour. Depending on the number of instances that your application is using, it can take longer than the specified wait time for the scale action to occur if the wait time is set very low. The minimum time between scaling actions
    is five minutes. Scaling actions cannot occur if any of the instances are in a transitioning state.
    ==========
    Does any one know the microsoft`s definition of 「All Instance」 ?
    Whether the virtual machines that are shut down but has been set into auto scaling group count as one of them?
    The question is that the response time, the data shows up in the management portal delays a lot comparing to the
    real time. I was wondering if the definition of the calculation described above is truly what the user`s want or not.
    I`m all ears to any information. Thanks in advance !! 

    Hello Tomo Shimazu,
    Instance is a presence of a service eg :- VM is an instance. Copy of VM is another instance which is 2 instances of VM.
    Although Microsoft’s pricing model is readily available and even offers a simple calculator (http://www.windowsazure.com/en-us/pricing/calculator/advanced/) to assist
    in the process, it may be difficult to know how much of each resource you will need to get an estimate.
    To understand on calculating the compute instances and the VM size, let’s first take a look at the VM role sizes offered by Microsoft.
    The prices per month for each, at the time of writing, are $30, $90, $180, $360, $720 from ExtraSmall to ExtraLarge respectively. So with the exception of the
    transition from ExtraSmall to Small, going to the next size VM is exactly twice the cost, which, is mirrored in the increase of resources you get at each level. With each step, CPU Cores, Memory, Disk Space, and Bandwidth are all doubled from the previous.
    If this is the case, then, is there any advantage to any one of these over the others? The answer is yes. In the majority of cases, the best bet will be to go with the small instance, with the reason being that because all of these resources scale equally
    to cost it is possible to achieve the exact equivalent to a larger VM simply by increasing the number of instances. For example 8 small instances is equivalent to one ExtraLarge instance, with the advantage of the fact that when not needed these small instances
    can be turned off and will cost nothing.
    By hosting the application in this manner, it increases the effectiveness of the number one reason that a business would transition to the cloud anyway – Scalability.
    Obviously 16 smaller instances can be more finely adjusted to the application’s usage than 2 ExtraLarge can. If traffic gets higher or lower than expected, two Small Instances can be added at $180/mo for the time that they are running, versus adding another
    ExtraLarge for $720/mo.
    The only exception to using the smallest instance, is in the case of the ExtraSmall, which offers only 1/20 of the bandwidth of the Small, making it only feasible
    for very lightly accessed applications or, more likely, a QA environment.
    From this point, it becomes much easier to estimate the compute instance requirements of migrating the application to Windows Azure. Take the current server(s)
    total resources (CPU, RAM, etc) and find how many Small instances it would take to recreate it. This gives a good starting point, however, remember that these instances can be turned on and off to meet demand, and beyond the first instance, there is no charge
    when the instances are off. This can lead to significant cost savings, and is the primary incentive to migrating to the cloud.
    For azure pricing information, refer
    pricing details.
    If you still unclear about pricing and billing, you may raise a service request with billing team
    here
    Hope this helps.
    Regards,
    Shirisha Paderu

Maybe you are looking for