All problems
Fourier Basis Feature Value
Problem
Evaluate a Fourier basis feature: cos(pi * order . state). The order vector holds non-negative integer frequencies, one per state dimension.
Hint
The all-zero order gives the constant feature 1.
Test cases
case 1
in: [[0.5],[1]]
expected: 6.123233995736766e-17
case 2
in: [[0,0],[1,1]]
expected: 1
case 3
in: [[0.25,0.25],[2,2]]
expected: -1
case 4
in: [[0.3],[0]]
expected: 1
Starter codePython
import math
def fourier_feature(state, order):
# Your code here
pass4 test cases · run your code against them in the editor