Concepts / Linear Function Approximation

Linear Function Approximation

A Fourier basis represents an approximation as a weighted sum of sine and cosine basis functions.

  • Programming

From Unknown Shape to Useful Estimate

A reinforcement learning system may need to estimate a value function whose complete shape is unknown. Rather than represent that entire shape directly, linear function approximation constructs an estimate from features and weights. Fourier basis functions are one important choice of features: they use sine and cosine functions with different frequencies, then combine their contributions through weights.

The central bookkeeping is simple: features provide separate signals, weights control the importance of those signals, and adding the weighted contributions produces the estimate.

Reading a Repeating Period

A periodic function is defined by repetition after a period T. The period identifies the length of the repeating structure: after one period, the function repeats the same pattern. Fourier series are naturally associated with this setting because they describe periodic functions as weighted sums of sine and cosine basis functions.

repeat after Trepeat after TPeriod Aone repeating patternPeriod Bsame patternPeriod Csame pattern
What part of a periodic function repeats, and how does one period map onto the next?

Combining Fourier Features

A Fourier basis uses sine and cosine functions as building blocks. Different frequencies make the basis functions vary in different ways. Each basis function supplies a feature, and its associated weight scales that feature's contribution. The approximation is the sum of the weighted contributions.

feature valuefeature valuefeature valueweighted contributionweighted contributionweighted contributionSine featurelower frequencyWeightscales contributionApproximationweighted sumCosine featurefrequency patternWeightscales contributionSine featuredifferent frequencyWeightscales contribution
How do sine and cosine features with different frequencies combine through their weights to approximate an unknown function?

Three-Component Fourier Bookkeeping

Construct a small illustrative approximation from one sine basis function, one cosine basis function, and another basis function with a different frequency.

Choose features: Use three basis features: a sine feature, a cosine feature, and a second feature with a different frequency.

Assign weights: Give each feature a weight. The weight determines how strongly that feature contributes.

Scale contributions: Multiply each feature's value by its associated weight to obtain that feature's contribution.

Add contributions: Add the three weighted contributions. The result is the approximation for the input being considered.

The approximation is a weighted combination of the three basis-function contributions. Adding more basis functions gives the approximation more components with which to represent a target function.

This example is deliberately about structure rather than a numerical result. The important trace is that frequencies determine which patterns are available, while weights determine how much those patterns affect the final approximation.

Turning Features into a Value

A linear value estimate turns feature values and weights into one prediction through a weighted sum. In a Fourier-based representation, the features may be values supplied by sine and cosine basis functions. The same broad mechanism applies more generally: represent the state through features, pair those features with weights, and combine the paired contributions into an estimate.

pairpairpaircontributioncontributioncontributionFeature 1feature valueWeight 1paired weightValue estimateweighted sumFeature 2feature valueWeight 2paired weightFeature 3feature valueWeight 3paired weight
How does a linear value estimate combine multiple feature values with their corresponding weights to produce one prediction?

A linear approximator is not necessarily uselessly simple. It can work well when its features are chosen appropriately. The representation supplied to the learning method is therefore a major design decision.

Why Representation Matters

Feature selection places prior domain knowledge into a reinforcement learning system. The designer chooses a representation that emphasizes patterns considered useful for the problem instead of presenting the learning method with an undifferentiated description. Because the feature representation strongly influences what the system can learn and generalize, the choice of features matters alongside the choice of learning method.

Representation choiceWhat the source establishesHow to use this distinction
PolynomialsListed as a feature-representation choice in the learning objectives.Treat as a representation family to distinguish from the other listed choices; construction details are not specified in this source pack.
Fourier basis featuresUse sine and cosine basis functions with different frequencies and combine them with weights.Choose when this feature structure is suitable, including settings involving continuous state spaces.
Coarse codingListed as a feature-representation choice.Recognize it as an alternative representation rather than as the same feature construction as Fourier basis features.
Tile codingListed as a feature-representation choice.Recognize it as an alternative representation rather than as the same feature construction as Fourier basis features.
Radial basis functionsListed as a feature-representation choice.Recognize it as an alternative representation rather than as the same feature construction as Fourier basis features.

Fourier Features in Reinforcement Learning

Fourier basis functions are valuable in reinforcement learning because they are easy to use and can perform well even when the function being approximated is unknown. This matters because reinforcement learning does not begin with a fully known function whose Fourier-series weights can simply be obtained from formulae. Instead, the system must learn about an unknown function while using a chosen representation.

The same broad feature-and-weight idea is relevant to multi-dimensional continuous state spaces. The source also describes a form of the Fourier basis for reinforcement learning problems in which the functions do not have to be periodic. Therefore, periodic Fourier-series intuition is useful for understanding the basis, but it does not by itself limit every reinforcement learning application to periodic functions.

alternative choicealternative choicealternative choicealternative choicealternative choicePolynomialsfeature familyTask representationfeatures supplied tolearningFourier featuressine and cosineCoarse codingfeature familyTile codingfeature familyRadial basisfeature family
What is the structural distinction between the representation choices named in the source?

Efficiency and Model Class

Linear approximation methods also differ in their practical trade-offs. LSTD favors data efficiency, but it has a higher computational scaling cost than the other linear methods described in the source. This makes LSTD a useful example of a broader design tension: using data efficiently can come with greater computational cost.

combineweighted sumprocessproduceFeatureschosen representationWeightsweighted sumValue estimatelinear modelInputrepresentationmodel inputNeural networkbackpropagation trainingValue estimatenonlinear model
How does information flow through a linear feature-weight model compared with a multilayer nonlinear model?

Nonlinear methods take a different modeling direction. The source includes artificial neural networks trained by backpropagation and variations of stochastic gradient descent among these methods. Their popularity in reinforcement learning has led to the term deep reinforcement learning. The key contrast is therefore between a linear feature-weight estimate and a nonlinear model based on neural networks and their training methods.

Mistakes in Feature Reasoning

  • Treating every basis function as if it had the same frequency.

    Different frequencies distinguish the patterns available to the approximation.

    Fix: Track frequency as a property that determines the kind of variation each basis function can provide.

  • Confusing a feature with its weight.

    The basis function supplies the feature, while the weight controls that feature's contribution.

    Fix: Separate the feature value from the weight that scales it, then add the weighted contributions.

  • Assuming that linear approximation is automatically too simple for useful value estimates.

    The source reports that a linear approximator can work well when its features are chosen appropriately.

    Fix: Evaluate the representation and the learning method together.

  • Assuming that reinforcement learning can always obtain Fourier weights from simple formulae.

    Simple formulae for Fourier-series weights apply when the function being approximated is known, while reinforcement learning commonly involves unknown functions.

    Fix: Recognize Fourier basis functions as a useful representation for learning about an unknown function.

  • Describing LSTD as both data-efficient and computationally cheaper without qualification.

    The source states that LSTD has a higher computational scaling cost than the other linear methods described.

    Fix: Remember both sides of the trade-off: data efficiency and higher computational scaling cost.

Practice the Trace

MEDIUM

Imagine an approximation with three features: a low-frequency sine feature, a cosine feature, and a sine feature with a different frequency. Explain, in order, what the features provide, what the weights control, and how the final value estimate is produced. Then state one reason Fourier basis functions can be useful when the function being approximated is unknown.

Hints
  • Begin with the distinction between a feature and its weight.
  • Mention that different frequencies provide different patterns of variation.
  • The final estimate is formed by adding weighted contributions.
  • For the final reason, connect Fourier features with ease of use and performance across reinforcement learning problems.
MEDIUM

A team wants a reinforcement learning system to use a linear approximator. Explain how choosing its features can add prior domain knowledge, and state the trade-off associated with LSTD that the team should remember.

Hints
  • Prior knowledge enters through the representation selected for the task.
  • The feature representation influences what the system can learn and generalize.
  • LSTD favors data efficiency but has a higher computational scaling cost than the other linear methods described.

Key Takeaways

  1. A periodic function repeats its structure after a period T.
  2. Fourier basis functions use weighted sine and cosine features, with frequencies determining available patterns and weights controlling contributions.
  3. A linear value estimate combines feature values and their weights through a weighted sum.
  4. Feature selection injects prior domain knowledge and strongly influences learning and generalization.
  5. LSTD favors data efficiency at a higher computational scaling cost, while nonlinear neural-network methods follow a different modeling direction associated with deep reinforcement learning.

Key Takeaways

  • Fourier basis functions approximate a function by combining sine and cosine features with weights.
  • The period describes repetition, frequencies distinguish patterns, and weights control each feature's contribution.
  • Linear value estimation depends heavily on the chosen feature representation, not only on the learning algorithm.
  • Fourier features, polynomials, coarse coding, tile coding, and radial basis functions are alternative representation choices identified in the source.
  • LSTD trades higher computational scaling cost for data efficiency, while deep reinforcement learning uses nonlinear neural-network methods.