Help with Loop to Rule Based Algorithm
- To: mathgroup at smc.vnet.net
- Subject: [mg114761] Help with Loop to Rule Based Algorithm
- From: Daniel Lockhart <daniel.lockhart at gmail.com>
- Date: Thu, 16 Dec 2010 05:48:37 -0500 (EST)
Hi all, I have been a long time Mathematica user, but have always had problems writing Mathematica code using rules from existing algorithms that utilize loops. Suppose I want to write a simple smoothing filter, but not use any built-in Mathematica algorithm. Just to make the point, I want the smoothing gain/coefficient to be a nonlinear function. So, I want this pseudocode: x_{1} = u{1}; for i = 2 to N alpha = f(x, u); x_{i} = x_{i-1} + alpha * (u_{i} - x_{i-1}); end for; if u is the input data, and f(x, u) is a nonlinear function of x and u. If alpha was constant and 0 < alpha < 1, x would be some sort of moving average of u. How can I do this in Mathematica without writing an explicit loop? I am guessing some from of recursive Map, but I am at a loss on how to start. Thanks!
- Follow-Ups:
- Re: Help with Loop to Rule Based Algorithm
- From: Daniel Lockhart <daniel.lockhart@gmail.com>
- Re: Help with Loop to Rule Based Algorithm
- From: Murray Eisenberg <murray@math.umass.edu>
- Re: Help with Loop to Rule Based Algorithm
- From: Daniel Lockhart <daniel.lockhart@gmail.com>
- Re: Help with Loop to Rule Based Algorithm
- From: Sseziwa Mukasa <mukasa@jeol.com>
- Re: Help with Loop to Rule Based Algorithm