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.

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&colon; 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.

  • 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!

  • Problem with moving average

    I have to create a report which displays rolling average of revenue.
    The report contains two columns week and avg revenue. I have to display only ten weeks from the current week.
    For each week the revenue should be calculated as follows;
    weeks     actual revenue     Avg revenue
    1     10          10     
    2     20          (10+20)/2
    3     30          (10+20+30)/3     
    4     40          (10+20+30+40)/4
    5     50          (20+30+40+50)/4
    6     60          (30+40+50+60)/4
    (current week-10 weeks)
    current week
    I have used Mavg(actual revenue, 4) to calculate avg revenue.
    I am getting the correct values. However if I apply a filter say weeks between current week and (current week-10 weeks), I am facing a problem.
    My (current week-10 weeks) is now showing avg revenue as 10 which is my actual revenue amount.
    But i would like to show the revnue amount as an avgerage of (current week-10 weeks) and previous three weeks.
    The filter to limit the number of weeks is applied before calculating the moving average. Is there anyway to calculate the moving average first and then apply the week filter to report.
    Pls help me solving this.
    Thanks

    Do this:
    Have the measure as :
    case when Periods."Weekdate" > TIMESTAMPADD(SQL_TSI_WEEK, -10 , CURRENT_DATE) then MAVG ("Sales Measures".Units, 4) else 999999999 end
    And then apply filter on the above measure column as :
    Case when Periods.Weekdate > TIMESTAM... ' is not equal to / is not in 999999999
    Let us know how it goes.
    PS : To prevent runaway query, you may want filter it further by Periods."Weekdate" > TIMESTAMPADD(SQL_TSI_WEEK, -15 , CURRENT_DATE)

  • Moving Averages and drilling

    Hey everyone,
    I've got the following scenario going on:
    A pivot table that has a product hierarchy and quantity sold along with a 5,10 and 20 day moving average. At the base level of the hierarchy (i.e. you haven't drilled into anything yet), the moving averages work correctly.
    But once you drill into the different product levels, the moving averages immediately stop making any sense. It's almost as if they are precomputed in some other order and then reorganized into a order that no longer makes mathematical sense.
    Does anyone know why this happens?
    Can anyone recommend how to get it to function as I would expect it to?
    thanks everyone!
    -Joe

    Serhan,
    If you are just aiming to smooth out your signal and reduce noise, than an FIR filter would work fine, but it sounds like you are trying to achieve an exact moving average.  Unfortunately, there are entire textbooks on filter design and getting the filter to accomplish that with great accuracy would be a feat.  It is true that the moving average is a form of the FIR filter.
    I had some old code that took the running average of 100 samples in SE, but I'll have to look for it when I get to work tomorrow.  I'll post again when Ifind it.
    I don't have any moving average VI's handy, but that would probably be the easiest way to accomplish this. Maybe someone can distribute their VI to Serhan?
    Rob K
    Measurements Mechanical Engineer (C-Series, USB X-Series)
    National Instruments
    CompactRIO Developers Guide
    CompactRIO Out of the Box Video

  • 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

  • Moving Averages in Labview SignalExpress

    Hi everyone,
    I am measuring power consumption values from a PC system at 25k samples/sec and looking for a way to calculate the 1-sec and 5-sec moving averages via Labview SignalExpress (Unfortunately I don't have Labview to custom-implement this). One person suggested using FIR low pass filter instead, but I am not quite sure what values I need to set for "number of taps" and "cutoff frequency" values to have it act like a 1-second and 5-second moving average. Any suggestions here?
    Also, does anyone have a .VI from Labview for a moving average functionality, which I can use in my Labview SignalExpress setup?
    Thanks,
    --Serhan 

    Serhan,
    If you are just aiming to smooth out your signal and reduce noise, than an FIR filter would work fine, but it sounds like you are trying to achieve an exact moving average.  Unfortunately, there are entire textbooks on filter design and getting the filter to accomplish that with great accuracy would be a feat.  It is true that the moving average is a form of the FIR filter.
    I had some old code that took the running average of 100 samples in SE, but I'll have to look for it when I get to work tomorrow.  I'll post again when Ifind it.
    I don't have any moving average VI's handy, but that would probably be the easiest way to accomplish this. Maybe someone can distribute their VI to Serhan?
    Rob K
    Measurements Mechanical Engineer (C-Series, USB X-Series)
    National Instruments
    CompactRIO Developers Guide
    CompactRIO Out of the Box Video

  • 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 price in case of goods receipt with free of charge

    Hello everyone,
    Need some inputs......
    Sometimes we receive materials from suppliers free of charge (e.g. warranty replacement) u2013 moving average goes down u2013 worst case 0,01 EUR/piece. This causes problems in government reporting and export documentation EX1 and clearance/pro-forma invoice) for deliveries to field engineers (Order type ZIS1, ZIS3 u2013 item cat. ZICA), because moving average price is used for the values in government reporting and on the invoices. In government reporting and on invoices we need to state a true value of the part.On the other hand, the value warehouse stock is depending on the moving average cost as well.Could you please let me know, how to handle such receipts from the supplier to have a correct stock value and correct values on invoices and government reporting?
    Thanks
    Deepthi...

    Hello Deepthi,
    It depends on your company policy. If you want to valuate the material along with the material purchased handled in moving average price, free consignment will bring down the MAP for the material.
    In that case, you can revaluate the material to the original price in MR21 transaction.
    If you are not going to handle the materials received free of charge along with the purchased material, you can go with another material code, with non valuated material type.
    But i guess, no company will be asking for another material code. So go for revaluation after the receipt of free consignment.
    Regards

  • Moving Average Price for Sales stock and Project stock of a material

    Hiya Gurus,
                     I am developing a report to display inventory details. My requirement is that I have to display the Moving average price of a material for all Valuation type. I also need to display the Moving average price if a material has got Project stock or Sales stock.
                     In MBEW table I can get the Valuation type and its Moving average price, but how can I find the moving average price for the same material if it has got Sales stock and project stock. Please let me know the table and field where I could get the relevant data.
                    Kindly help me on this, it would be deeply appreciated.
    Cheers,
    ZIa

    Hi
    can you look at tables
    EBEW                             Sales Order Stock Valuation
    QBEW                             Project Stock Valuation
    Nat

  • SSRS 2008 R2 - Add moving average to column group

    I have a column group of dollar amounts.  The row is a year/month.  I would like to add a moving average column to the right of the last 6 months.  My SQL Server data source is already complex enough and I'd really prefer not to add a column
    there.  Is there anything I can do within the report itself?  Some way to reference the previous records in a matrix?
    Thank you!

    Hi mateoc15,
    According to your description, you have a matrix in your report. Now you want to calculate the average value of last 6 month. Right?
    In Reporting Service, we can put custom code into report to deal with complicated logic. Add one more column/row inside of group and call the functions defined in custom code. For your requirement we modified Robert’s code to achieve your goal. We tested
    your case in our local environment with sample data. Here are steps and screenshots for your reference:
    Put the custom code into report:
    Private queueLength As Integer = 6
    Private queueSum As Double = 0
    Private queueFull As Boolean = False
    Private idChange As String=""
    Dim queue As New System.Collections.Generic.Queue(Of Integer)
    Public Function CumulativeQueue(ByVal currentValue As Integer,id As String) As Object
    Dim removedValue As Double = 0
    If idChange <> id then
            ClearQueue()
                    idChange = id
                    queueSum = 0
                    queueFull = False
                    CumulativeQueue(currentValue,id)
    Else
                    If queue.Count >= queueLength Then
                                    removedValue = queue.Dequeue()
                    End If
                    queueSum += currentValue
                    queueSum -= removedValue
                    queue.Enqueue(currentValue)
                    If queue.Count < queueLength Then
                    Return Nothing
                    ElseIf queue.Count = queueLength And queueFull = False Then
                    queueFull = True
                    Return queueSum / queueLength
                    Else
                    Return (queueSum) / queueLength
                    End If
    End If
    End Function
    public function ClearQueue()
    Dim i as Integer
    Dim n as Integer = Queue.Count-1
    for i=n To 0 Step-1
                    queue.Dequeue()
    next i
    End function
    Add one more row inside of group, call the function defined in custom code.
    Save and preview. It looks like below:
    Reference:
    Moving or rolling average, how to?
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou (Pactera)

  • Moving average price

    Hai all MM gurus,
    While invoice posting, system is showing the error message " Moving average price is negative for the material ".
    How to post the invoice .

    Hi,
    In the material master the moving average price is negative.
    Please use MR21 and change price so that the MAP will be
    postitive then you can verify  the invoice
    G.Ganesh Kumar

  • Moving average Price for Material is Negative

    HI Friends,
    I am doing MIRO for PO where its giving me error while posting the Invoice that
    Moving average price for material is negative
    Can any please help me to resolve this.
    what would be the implications if the price difference is too high b/w MAP in Invoice .
    Thnaks
    Purna Nalluri

    It is ofcourse bcoz there is price difference in the between PO and IR....
    so as per the calculations the MAP becomes negative....
    The formula for it is :
    Difference/Current stock holding + current moving average...
    Pls check you price entered at PO and IR....
    There are no any implecations...excepts the price differece is reflected in the MAP of MMR....
    hope it helps...
    Regards
    Priyanka.P
    Edited by: Priyanka Paltanwale on Sep 23, 2008 7:28 AM

  • Error: moving average price negative while doing MIRO

    Hi Experts,
    I am doing MIRo for PO where its giving me error while posting the Invoice that:
    Moving average price for material is negative: XSEPSNPW045CX 1044
    The MAP maintained in material master is 39,979.71 and in the invoice and GRN is 69,049.58. 
    Can any please help me to resolve this.
    what would be the implications if the price difference is too high b/w MAP in Invoice amount.
    and
    what happen when we paintain the amount in mr21.
    Regards,
    Sonali.

    Hi,
    Pls check your price in MMR (MAP price) and then check the IR price of material ....
    Example:
    MMR MAP Price = 5.00 EUR
    If IR price = 30 .00 Eur
    IN YOUR CASE:
    The MAP maintained in material master is 39,979.71
    and in the invoice and GRN is 69,049.58.
    So MAP PRice defined in the MMR is lesser than the IR price...
    so the MAP will get negative...
    Hope it helps...
    Regards
    Priyanka.P
    AWARD IF HELPFULL
    Edited by: Priyanka Paltanwale on Sep 2, 2008 7:49 AM

  • Using Moving Average Materials with MF42N (Repetitive Production)

    Version: ECC 6.0
    I have a "Is this possible" question.  I know this isn't a best business practice, but thought I'd anyway.  Here goes ...
    A material that uses Moving Average (referenced as Material123 below) has the following two materials in its BOM:  (1) Moving Average (Material456), and (2) Non-valuated material, material type = LEER (Material789).
    The 1st material in the BOM (Material456) is Liquid Oxygen.  This product is purchased from a vendor and received into inventory via movement type 101.
    The 2nd material in the BOM is an empty cylinder (Material789)
    The parent material (Material123) being produced is gaseous Oxygen (Oxygen in gas form).
    Basic production process:  Liquid Oxygen is the raw material, it is pressurized and stored in a cylinder in gaseous form (for clarity, you've probably seen cylinders before, the two obvious examples of cylinders are propane cylinders used on barbeques and helium cylinders used to blow-up balloons).
    Assumptions:  (1) We do not want to do a cost roll, (2) We want to report production (TCode=MF42N) to consume the Bulk Oxygen (Material456) and the cylinder (Material789), and create the finished good (Material123), and (3) We do not want to burden the cost of the parent material (Material123) with direct costs, we only want the material costs.
    If you read through the assumptions you can see that this is not proper accounting for a production process (i.e. the direct costs in the production process are not capitalized -- labor, power, etc.), if you can get beyond that I was wondering if anyone has ever set anything like this up?  I tried to set this up and report production in my test environment, I got the materials created, the BOM created, but when I tried to report production it gave me an error, it needs a production version and/or a cost collector.
    If anyone has done anything like this I'd be interested in knowing if it is possible to report production with a setup like this.  Thanks.

    Using CO production orders may solve your problem. They dont need PP or product costing to be implemented. Costs can be flexibly posted and there are not many demanding requirements for this.
    Tcode:KKF1
    Link: [http://help.sap.com/saphelp_erp2004/helpdata/EN/82/e72326b11411d29f60080009b0db33/frameset.htm]
    Thanks
    Naveen

Maybe you are looking for