8 point moving average filter

How to implement an 8 point moving averge filter for a sample size of 1000?

There are many ways to do this.  One of my favorite is to just use an FIR Filter.  But the most straight forward way is to use the Mean Pt By Pt VI inside of a FOR loop.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines

Similar Messages

  • Moving average filter

    I have a problem that I will describe:
    I am receiving a continous stream of data,  in the form of an array.
    however I want to do some processing on a smaller subset of the array, and obtain similar results to as if i was using the whole array.
    the processing is:
    1) recevie data: 10 points
    2) take mean of these 10 points
    3) divide array/mean
    and more processing which is not important.
    the original array can have up to thousands of points. I know I can use a moving average, which i have done. so the average of the points 1:10 and 11:20 is the same as points 1:20.
    however the problem is the third step, dividing each data by the mean.
    in the end i want to plot the subset outputs, and i want it to be similar to processing the enitre data set.
    Im not an expert in filters and all, but is there a good way to do this?
    because the result i am getting now is quite choppy and unsmooth.
    thanks!

    If you are averaging data, and it is choppy, there are likely multiple things wrong.  The data is only going to be as good as the the sensor can measure.  And if you are getting crappy data at the sensor, then software should not be the one to fix it.  Fix the environment so the sensor gets the best data it can before software has to be involved.
    That being said some times software filtering is needed and that's okay.  Try to post what an example of your code.  It is hard to understand what you are trying to do.  Do you want a moving window of data to average?  Or are you trying to understample where 10 values are now 1?
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • Filter slope of multipass moving average

    Hey guys,
    here is a picture of the frequency response of a multipass moving average filter. The number of stages tells you how often the data is passed through the filter.
    As I am interested in the different slope behaviours of the different stages I wanted to ask you how to determine the slope.
    Do I take the envelope to calculate the roll off (=slope) of the filter?
    Actually it should be 1 pass (= 1 stage) is 20dB/Dekade, 2 passes = 40dB/dekade and so on...
    I hope you can help me.
    Kind regards
    Slev1n
     

    The equation for the envelope of the frequency response can be obtained by noting that the absolute value of the numerator sin(wM/2) varies between 0 and 1.  So its upper edge is 1, and you can replace sin(wM/2) with unity, to find the upper envelope of H(w). (This envelope only applies for wM/2>Pi, which is the first zero of the numerator.)  Thus you get
    envelope of H(w)= 1/[M*sin(w/2)]^Mp. 
    Note also that when w/2<<1, you can use the approximation sinx ~= x:
    envelope of H(w) ~= 1/[M*w/2]^Mp
    Therefore the envelope of H(w) is proportional to 1/w, 1/w^2, 1/w^3 when Mp=1,2,3.  Now you see why the envelope's slope is 20, 40, 60 dB/decade when Mp=1,2,3.  (Apply the equation for gain in dB, when w changes by 10X.)  The approximation above is decent only when 2Pi/M < w << 1.  If the number of moving average points, M, is small, for example a 5 point moving average, then there will be no frequencies which satisfy the preceding inequality for w.  But you chose M=500, so there is a range of frequencies where the 20 dB/decade rolloff is apparent.  If you look carefully at your plot, you will see that the frequency response starts to deviate from 20 dB/decade as frequency f (=w/2Pi) approaches 0.5 (the Nyquist frequency).  This is because you are getting into the range where sin(x)~=x is not accurate.
    Final comment: Since you apparently care about the frequency response properties of your lowpass filter, you might want to use a different filter.  Other FIR and IIR filters have flatter passbands, sharper rolloff around the cutoff frequency, and lower sidebands.

  • SSRS 2008 Column Chart with Calculated Series (moving average) "formula error - there are not enough data points for the period" error

    I have a simple column chart grouping on 1 value on the category axis.  For simplicity's sake, we are plotting $ amounts grouping by Month on the category axis.  I right click on the data series and choose "Add calculated series...".  I choose moving average.  I want to move the average over at least 2 periods.
    When I run the report, I get the error "Formula error - there are not enough data points for the period".  The way the report is, I never have a guaranteed number of categories (there could be one or there could be 5).  When there is 2 or more, the chart renders fine, however, when there is only 1 value, instead of suppressing the moving average line, I get that error and the chart shows nothing.
    I don't think this is entirely acceptable for our end users.  At a minimum, I would think the moving average line would be suppressed instead of hiding the entire chart.  Does anyone know of any workarounds or do I have to enter another ms. connect bug/design consideration.
    Thank you,
    Dan

    I was having the same error while trying to plot a moving average across 7 days. The work around I found was rather simple.
    If you right click your report in the solution explorer and select "View Code" it will give you the underlying XML of the report. Find the entry for the value of your calculated series and enter a formula to dynamically create your periods.
    <ChartFormulaParameter Name="Period">
                      <Value>=IIf(Count(Fields!Calls.Value) >= 7 ,7, (Count(Fields!Calls.Value)))</Value>
    </ChartFormulaParameter>
    What I'm doing here is getting the row count of records returned in the chart. If the returned rows are greater than or equal to 7 (The amount of days I want the average) it will set the points to 7. If not, it will set the number to the amount of returned rows. So far this has worked great. I'm probably going to add more code to handle no records returned although in my case that shouldn't happen but, you never know.
    A side note:
    If you open the calculated series properties in the designer, you will notice the number of periods is set to "0". If you change this it will overwrite your custom formula in the XML.

  • Moving Average in a Report Section

    Hi there,
    I am displaying a measure in a chart that has three data points. The measure is 4 day moving average of a metric. Let's say my query brings back the last 6 days, which enables me to calculate the 4 day moving average for days 4, 5, and 6.
    I use the Previous() function to calculate the moving average:
    =(metric + Previous(metric) + Previous(Previous(metric)) + Previous(Previous(Previous(metric)))) / 4
    I don't want to show days 1, 2, and 3, so I filter these out of the chart and wrap a NoFilter() around the moving average. Everything is good so far.
    The problem arises when I section on a dimension. I can't seem to get the correct values unless I display all 6 data points in each section. NoFilter() doesn't seem to work.
    Has anyone run into this before? Does there exist a solution for this?
    Any help would be greatly appreciated.
    Thanks,
    Allan

    I figured it out:
    NoFilter([[4wkMvAvgMeasure]]) ForEach ([[day]]) In Section
    Thanks,
    Allan

  • An averaging filter that tightens depending on slope??

    Hello all,
    I have an application where a variable (DBL scalar) is shown in a graph to be bouncing above and below the target setpoint @ approx 1-5sec intervals.  In other words, if the setpoint is 1500lbs, the variable bounces between 1250 and 1750lbs, which is +/-250lbs and it does this bouncing @ approx 0.2 to 1 Hz.  The customer wants me to show the average instead of the real-time.... so the graph would show a horizontal line @ 1500lbs in the above example.  They dont want to see the ripple.  So, I pulled out the "Mean PtbyPt.vi" function and as long as I increase the sample length adequately it does exactly what my customer wants.  Heres my problem...  When the process starts or ends and the weight returns to zero lbs, the mean is very, very slow to respond.
    Is there a way to make it "come into" and "out of" the target zone quickly, but filter the heck out of it when it is in the zone?  I am thinking of making my own function that would look @ the slope.  If the slope is less than a certain threshold, then the "Mean PtbyPt" sample length is long, but if the slope is greater than a certain threshold, then the "Mean PtbyPt" sample length is short.  Since I am just learning labview now and I have never used any of the filters or signal processing functions before, I feel like I might be recreating something that already exists?  Would any of these help me?  FIR, IIR, Chebyshev, Butterworth?  I am glad to learn all of these things, but to accomplish my task efficiently without chasing my tail, can anyone point me in a helpful direction?
    Thank you very much for any input.
    respectfully,
    frenchy

    Hai,
    For the task like reducing jitter moving average serves good.  It's takes "number of points" to average.  A simple example is if you had a data set with 100 data points, the first value of the moving average might be the arithmetic mean (one simple type of average) of data points 1 through 25. The next value would be this simple average of data points 2 through 26, and so forth, until the final value, which would be the same simple average of data points 76 through 100.
    The VI can be found in the following link: http://zone.ni.com/devzone/cda/epd/p/id/82
    Hope this helps.
    With regards,
    JK
    (Certified LabVIEW Developer)
    Give Kudos for Good Answers, and Mark it a solution if your problem is solved.

  • Exponential Moving Average - EMA - in PowerPivot

    Hello All
    We´re having a challenge trying to put the [20] (trading days) Exponential Moving Average (EMA) in our data model in PowerPivot.
    Here is the EMA formula and sample spreadsheet:
    http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:moving_averages
    Pasted the formula here for convenience:
    SMA (simple moving average): [10] period sum / [10]
    Multiplier: 2 / ([Time period] + 1) )
    EMA: {Close - EMA(previous day)} x multiplier + EMA(previous day).
    Sample spreadsheet
    http://stockcharts.com/school/data/media/chart_school/technical_indicators_and_overlays/moving_averages/cs-movavg.xls
    In our model the fact table have these columns:
    Symbol Date Open High Low Close Volume
    And in the Calendar table we´ve identified the trading days (Calendar[TradingDayNumber]) as 1 so we can count them back.
    We want the EMA calculated field in a pivot table like this
    Filter context: a date selected on Calendar[FullDate]
    Row context: FactTable[Symbol]
    Values: FactTable[Close]
        FactTable[EMA 20D] >> Missing
    So far we got these calculated fields:
    Period
    =20
    Ema Multiplier
    =2 / ([Period] + 1)
    Average 20D CLOSE
    =IF([Sum of CLOSE]=BLANK(),BLANK(),(CALCULATE(AVERAGE(FactTable[CLOSE]),FILTER(ALL(Calendar),Calendar[TradingDayNumber]<=MAX(Calendar[TradingDayNumber]) && Calendar[TradingDayNumber]>MAX(Calendar[TradingDayNumber])-[Period]))))
    But it looks like the EMA formula contains a self reference from previous values, and it also starts from a SMA (Average 20D CLOSE) value.
    How can we do it?
    Thanks in advance. I highly appreciate your support.

    Nico,
    Is this still an issue?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • How do I create an n-point running average VI?

    I've been programming in sequential written languages like C for many years now. I've been using LabVIEW for the last 4 months and am having problems writing an n-point running average VI. It is really bothering me, because this would be really trivial in C or anything else. But for some reason I can't conceive how I would do this in LabVIEW. I used LabVIEW 5 for the bulk of that time, and we just upgraded to LabVIEW 8 last week so I've been learning it. Wow, some pretty big differences between the two but the gist is the same.
    I have a 5-point running average subVI written that uses a run-once while loop with shift-registers that keep their value between subsequent VI calls. This works for what I need, but have 2 problems I would like to overcome.
    1. I can't have multiple instances of the same subVI in my top-level VI program because the way the shift-registers are keeping their value between subsequent VI calls. I have to make duplicates of the .vi file (i.e., 5_point_running_average.vi, 5_point_running_average_2.vi) in order to keep all the shift registers seperate.
    2. I want it to be an n-point running average. Currently I have to jump into the VI and add another shift register to add another point. I often change my sample rate, and thus being able to have a different averaging window is really handy.
    So the VI takes 2 inputs:
    n - (integer) the number of points to computer the average over.
    in - (real) the current data point.
    output:
    out[i] = (in[i] + in[i-1] + ... + in[i-n-1])/n
    I've also thought about the possibility of needing a 3rd input that is "instance" which might help keep variables within the subVI separated and thus not needing separate duplicate files.
    In case you are wondering, I'm using a running average to make digital HUDs easy to read. The actual data that I'm recording to file will not be going through the running average function, because as you can see by the output function, there will be a phase shift in the output. At high sample rates, the digital displays can be moving very rapidly and that makes them hard to read.
    Other recommendations as to how to make digital displays easy to read to help operators while performing tests? As for instantaneous data smoothing, so to speak. I already make the displays very large if they are critical.
    I'm very interested in this n-point running average solution. I've been scratching my head over it for awhile now and am quite stumped on how to approach this in LabVIEW.
    Help is very much appreciates,
    -nickerbocker

    The atomic operations (delete/insert) MUST do the following:
    When you insert into array, all higher elements need to be moved up one slot, then the element is inserted.
    When you delete from array, the lement needs to be deleted and all higher elements moved down one slot
    Both operations involve an array resizing operation and data shuffling in memory.
    How can LabVIEW be sure that the memory can be re-used? What if your code would delete one, but insert two at each iteration? It might well be that the LabVIEW compiler properly re-uses the memory in your particular case, but there are no guarantees. A five element array is peanuts. so it would probably be difficult to notice a difference.
    You might want to run a benchmark of the different algoritms using a huge buffer.
    "First call?" is defined as followes in the online help:
    First Call? returns TRUE the first time the VI runs after the first top-level caller starts running, such as when the Run button is clicked or the Run VI method executes. If a second top-level caller calls the VI while the first top-level caller is still running, First Call? does not return TRUE a second time.
    It will only be true exactly once during the entire execution of the toplevel VI, only the first time it is called from anywhere.
    LabVIEW Champion . Do more with less code and in less time .

  • Moving average price not updatet when sales order stock

    Sales order stock is ioncluded in calculating moving average (at goods receipt there is no new valuation type created)
    It is okay with replenishment orders (regular stock)
    I first thought it had to do with Spec. Stk Valuation indictator (but this one is set to 'M', which seems right for me.
    Does anyone have a clue what I can do so my moving average value is also calculated based on sales order stock and not only regular stock?
    Kind Regards
    Kevin
    Edited by: Kevin Gielen on May 5, 2010 2:44 PM

    Spl Stock Valution must be - A (not M) to valuate along with normal stock .
    Ensure following configuration is there
    1. create Requirement class in OVZG . Maintain required account assignment category under account assginment subscreen
    2. Create requirement type in OVZH . assign this req.class to req.type
    3.Assign requirement type to sales item categories for which you need this VSO functionality
    4.Goto SM30 and give table V_T459K_K ,mainatain ,for your requirement class under valuation field maintain M or A(put F1 for moreinfo)
    5.Take SD consultant help to setup schedule line category(SC) for this item category ,it should have account assignemtnt category and PR order type - VOV6 and assign this SC to item category in VOV5
    6. Now create SO which will populate the above created item category (if not check with SD consul to populate the above item category)
    7.convert the PR generated through above SO into PO
    8.In PO under account assignment tab you could see BSX account and it must be greyout .
    9.Do GR ,stock will be updated in MBBS report.
    it resolves your requirements
    check point in each transaction:
    after SO ,check VBAP- KZBWS = M or A (which you have maintained in requirement class)
    PR from SO, EBAN-KZBWS =M or A and PO also will have EKPO-KZBWS = M or A

  • Moving average price as price control in material master: Erroneous entries

    Dear All,
    Recently we did a price control change from standard price to moving average price for one of our clients and scenario testing was done. We came across the following issue at the IR point and this error occur  time to time ( not for all POs )Following steps were followed
    Scenario
    1. Create a PO for 1000 Kg of material A @ 1USD
    2.GR the purchase order- at this point correct values are passed to stock account
    3.consumed 250 Kg from the above material and from the same batch- correct values are passed to the accounts correctly
    4.invoice verification is done for the above PO with a price variance of 100 USD. The error occur at this time ( some times )
    Correct entry:
    Dr GR/IR account 1000
    Dr Stock account 75 (Price variance is charged proportionately charge to the balance stock)
    Dr price variance 25 (Price variance is charged proportionately on the consumed stock)
    Cr Vendor 1100
    But sometimes the value does not pass accurately for the same PO. Accounting entries are as follows.
    ( this is same scenario with new purchase order with different master records )
    Dr GR/IR account 1000
    Dr Stock account 100 (Total price variance is charged to the stock account and its incorrect this should be only 75 as explain above )
    Cr Vendor 1100
    This error occurs sometimes even though the vendor master record and purchase orders are sand same as the time of pass correct entries  . All these time GR based invoice verification tick has activated in PO as well as vendor master .
    Appreciate your advice.
    Tks
    Sandagomi
    Edited by: Sandagomi Ranasinghe on May 9, 2010 9:25 AM

    Thank you for the information. But this is not the  system behavior , system proportionately add the price variance to the stock qty which is remaining in the stock also it proportionately charge the price variance to the price variance account which is consumed before the invoice verification.But time to time it passes the incorrect entries.
    eg , Create a PO for 100KG @ 1USD
           GR                     100KG
           Consumed           25
          IR , here we IR at higher value than the PO price
         PO value is USD 100
        IR    value    USD 100 + 12 = 112
    Correct IR entry : Vendor              CR    112
                                 GR/IR                 Dr    100
                                 Stock                 DR      8 ( 75% of the stk is reaming in stk so relevant variance is USD 8 )  
                                 Price variance   DR      4  ( 25% of the consumed , so relevant variance is USD 4 )
    And this is accurate with accounting principles and standards .
    Actually system correctly calculate the above entries  . but some times it pass the incorrect entry , this is my issue.
    In the  erroneous entry it does not segregate the price variance , If we consider the same scenario as above at the time of erroneous entry the system pass entries as below:
                                Vendor              CR    112
                                 GR/IR                 Dr    100
                                 Stock                 DR     12 ( add 100% which is incorrect )
    This is incorrect .

  • Moving average price in Semifinished material.

    Dear All,
          Our client wants to go for moving average price in case of semifinished material, which is supposed to be normally standard price. The problem is the MAP is not getting updated after the GR against the production order. What settings I need to check in cusomization from PP point of view to solve this problem. Ideally the summation of cost of raw materials has to be the cost of semifinished material.
    did the settlement and the MAP got updated. There are few questions I want to ask u are?
    1. What MAP should I keep when I create the material for the first time?
    2. What the base to calculate the target cost in production order? Currently the target cost is zero for that the varience is hugh which will be going to affect the MAP in a big manner after setllement? What should I do in that case?
    Ur valuable inputs are awaited at the earliest. It's urgent.

    Kindly go thoroug following it will solve your issue
    Genrally SAP suggest Std price for semi & fin
    but some company are useing MAP so i think the client want  MAP then also it will not create any problem but this is laways FICO decision
    now MAP is not getting updated
    while goods movement system update G/L AC automatically the price used for updating the GL is either std or MAP depending on which is maintain in material master
    your MAP will get updated only after settlement of Production order If your production is make to order in that case costing is against Sales order & no issue of settlemnt of Production order so MAP will not be updated in MTO
    which price you should maintan in material master & target cost & variance
    initally u upload master data with price 1 After that u take costestimate run & realse the price that will be std price Now you can see the varinace along
    after realsing the cost estimate you can chane MAP in mr21/22
    You can maintain both the prices in material master but while GL AC updating system check the price control & then pick price
    but it is advisable to have STD PRICE

  • Moving average price in case of semifinished product.

    Dear All,
    Our client wants to go for moving average price in case of semifinished material, which is supposed to be normally standard price against our advice. The problem is that MAP is not getting updated after the GR against the production order. What settings I need to check in cusomization from PP point of view to solve this problem. Ideally the summation of cost of raw materials has to be the cost of semifinished material.
    I did the settlement and the MAP got updated. There are few questions I want to ask u are?
    1. What MAP should I keep when I create the semifinished material for the first time?
    2. What the base to calculate the target cost in production order? Currently the target cost is zero for that the varience is huge which will be going to affect the MAP in a big manner after setllement? What should I do in that case?
    Ur valuable inputs are awaited at the earliest. It's very very urgent.

    Hi
    There will not any big problem if your client insists upon MAP for the material instead of your suggestio for having S as per std. SAP suggestions. There will not be any change in material price during confirmation if you have V indicator but if you have S as indicator there will be change in price due to costing and settlement. It is not that system will not do anything for the materials having V indicator, check the field value for Standard price , it gets updated. Your costing calculation completely depends uopn the settings that has been customised in OPN2 i.e the settings available for valuation. You cancompletely control all these.
    Pirce for your semifinished  should include the inputs to it and any other parameters which you would like to add. You can always change the price manually with MR21 if you have Zero stock.
    Best Regards

  • Moving average price in material master

    Dear All,
    M client is in  manufacturing process(variant configuration) having make to order scenario (Non-Valuated).
    We are having steel and ring business, For Steel business we are producing in house/subcontracting and  For Ring we are sending Raw material/Semi-finished goods to Sub-contractor for which he is charging processing charges. Raw material/SFG(semi-finished goods) provided to subcontractor is SFG for steel business.
    We are doing movement type 912 E for sending goods for subcontracting (sales order is attached) and while doing G/R through MIGO processing charges are debited and credit goes to gr/ir account,Upto this point I am ok with costing as visible from sales order analysis(KKAC).
    Now In our scenario if out of 6000 rings (as defined in sales order)customer is rejecting 1000 rings we have to detach that sales order through movement type 411 E and bring to our own stock or by movement type 412 E attach to another sales order .Also We are using 413 E movement type for transferring unsold goods to another sales order.
    In 411 E and 412 E movement types system takes moving average price (maintained originally ) and by using movement type 413 E no value is transferred only quantity is transferred (because of non-valuated scenario).
    Now if system picks original price maintained say at re.1 my costing for detached and attached sales order are incorrect .
    Example
    Material master(A) accounting view
    Map     1
    Stock     100               total value     100
    Sales order 1(10 tonnes)A (finished product)                    
    Cost     1000                              
    Revenue     800(5 tonnes)                         
    sales order 2
    cost b/f          5
    Revenue        800(5 tonnes)
    Now if 5 tonnes are detached from sales order it picks price from
    Master i.e Re.1 so Rs.5 is taken to own stock through mtype 411 E
    Or it takes Rs.5 to another sales order 2 as cost of 5 tonnes .
    Now my sales order 1 will show loss of Rs.195(995-800) and sales order2 shows profit of Rs.795.
    I want to know whether system is behaving correctly or some customization is to be done.
    Thanks and Regards
    Vijay
    Edited by: VIJAY MATLANI on Oct 13, 2008 5:28 AM
    Edited by: VIJAY MATLANI on Oct 13, 2008 5:30 AM

    Hey
    Check have you made any purchasing documents, with reference to material.
    And anybody played MR21 for the particular material?
    Thanks
    Raman

  • Standard or Moving Average Material Cost

    If we have PO price / costs plus shipping costs....can we use these to calculate the product cost whether standard or moving average?
    Thanks in advance
    Message was edited by:
            Satish A Kumar

    The Moving Average Price (MAP value) = Total Valuated Stock value / Total stock quantity.
    At any point of time, If you do a Goods receipt for a Purchase Order, the MAP value is re-calculated at the price at which the goods are inwarded.Thus the MAP value is subject to changes from time to time.
    The standard price is however unaffected by this.
    The Product costing,therefore, for materials with price type "V" is linked to the MAP value of material. Where as for materials with Price type "S" - i.e standard price, the product costing is not affected.

  • Creating Trendline of 50 Period Moving Average

    HI, im trying to plot my graph in LabView and trying to do create a treadline of 50 period moving average like in excel.
    is it possible for me to do it in LabView?
    i have tried General Polynomial Fit VI and some other VIs in Fittings but cant get anything close to the way i want
    any ideas? anyone?
    Solved!
    Go to Solution.

    Charlie, There's a better VI called "Mean PtByPt". Look in the palette "Signal Processing >> Point by Point >> Prob & Stat >> Mean". One added benefit: this VI gives valid data for the first 50 points, even though the mean is not "fully developed" or "stabilized" during the first iterations. (Also, keep in mind that "Delete from Array" and "Build Array" primitives make a call to the memory manager, meaning memory copies for large arrays and fast loop rates will result in a CPU bottleneck. Using circular buffers is one way to mitigate this limitation.)
    64864050, try adapting this code to fit your needs:
    a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"] {color: black;} a.lia-user-name-link[href="/t5/user/viewprofilepage/user-id/88938"]:after {content: '';} .jrd-sig {height: 80px; overflow: visible;} .jrd-sig-deploy {float:left; opacity:0.2;} .jrd-sig-img {float:right; opacity:0.2;} .jrd-sig-img:hover {opacity:0.8;} .jrd-sig-deploy:hover {opacity:0.8;}

Maybe you are looking for