Gaussian fitting of ALVINN output

This notebook illustrates how the Gaussian fitting approach that is used in ALVINN is very robust to noisy neural network outputs.

Definitions

Statistics package (to generate random noise)

<< Statistics`NormalDistribution`

Gaussian distributed random noise

r[s_:  .1]  := Random[NormalDistribution[0, s]]

Gaussian function

f[x_,  μ_, σ_] := 
      Exp[(-(x - μ)^2)/(σ^2)]

Simulation parameters

Simulated NN error

noise  = 0.3;

Sample steering direction

steering  =  0.5;

Width of Gaussian function

width  =  0.2;

Gaussian fitting

Plot idealized output of ALVINN

gActual  =  
        Plot[f[x, steering, width], {x, -1, 1},  Frame -> True,  
          PlotRange -> All,  GridLines -> {{0, steering}, None},  
          Axes -> None,  
          PlotStyle -> {RGBColor[1, 0, 1]}];

Idealized training data

data  =  Table[{x, f[x, steering,  width]},  {x, -1, 1, 
                2/29}]  //  N  //  Chop;
gTraining =  
        Show[Graphics[{RGBColor[1, 0, 1], PointSize[ .02], 
                  Point[#]} &  /@  data],  
          Frame -> True];

Simulated NN output

nn  =  {#[[1]], 
              Max[Min[1. ,  #[[2]] + r[noise]], 0]} &  /@  
          data;
gNN  =  
        Show[Graphics[{RGBColor[1, 0, 0], PointSize[ .02], 
                  Point[#]} &  /@  nn],  
          Frame -> True];

gOut1  =  Show[gTraining, gNN];

Best Gaussian fit

Function to optimize

tmp1  =  {f[#[[1]], μ,  width],  #[[2]]} &  /@  
          nn;
tmp2  =  ((#[[1]] - #[[2]])^2) &  /@  
          tmp1;
err  =  Plus  @@  tmp2

Plot optimization function

gOut2  =  
        Plot[err,  {μ, -1, 1},  Frame -> True,  
          PlotRange -> All,  Axes -> False,  
          GridLines -> {{0, steering},  None}];

Find minimum of optimization function

bestFit  =  μ  /.  FindMinimum[
            err,  {μ, steering}][[2]]

Plot resulting steering hypothesis

gBestFit  =  
        Plot[f[x, bestFit, width], {x, -1, 1},  Frame -> True,  
          PlotRange -> All,  GridLines -> {{0, steering}, None},  
          Axes -> None,  
          PlotStyle -> {RGBColor[1, 0, 0]}];

gOut3  =  Show[gActual,  gBestFit];

Summary of results

Show[gOut2];
Show[gOut1,  gOut3,  PlotRange -> All];