Assignment 1: Agents Homework

HOMEWORK MOTIVATION:  There is no "true" way to frame an artificial intelligence problem.  The authors of your textbook have their favorite ways, but I have a different favorite way.  I want you to be literate in the two representations, how they differ and how they are similar.  I am also having you continue your MATLAB tutorial, but with some more emphasis on probability and statistics.

GOAL: Learn two different ways to frame an AI problem, and get better with MATLAB.
  1. Problem 2.5 a, c, d: Keep It Simple
  2. Repeat problem 2.5 a,c,d, but instead of doing a PEAS description do a State-Action-Consequence description.
  3. Play with the potential fields lab by writing code to interface with the server.  Make the robot move forward.  Report on problems you encountered, observations you made, and any bugs in the code.
  4. In statistics, we frequently estimate the mean and standard deviations of a probability function using a set of samples obtained from the probability.  I want you to play with estimates of the mean and standard deviation while learning more about MATLAB.  You will do this by trying variations of the following code segment.  Create plots for all values from the following set:  (NUM_SAMPLES, NUM_TRIALS, TRUE_MEAN, TRUE_STD) from {(1000,100,-50,5),  (1000,100,25,5), (1000,100,-50,25), (20,100,-50,5), (1000,5,-50,5)}.  Explain why you think the plots are different.
% The percent symbol is the comment symbol in MATLAB.
NUM_SAMPLES = 1000;   % The number of observations that we'll take from a probability function.
NUM_TRIALS = 100;   % We'll take this number of observations a bunch of times to see how our estimates change.
TRUE_MEAN = -50;  % The true value of the mean.
TRUE_STD = 5;   % The true value of the standard deviation.

mhist=zeros(1,NUM_TRIALS);  % Create a vector (initialized to zeros) where we can store estimates of the mean.
shist=zeros(1,NUM_TRIALS) ; % Create a vector (initialized to zeros) where we can store estimates of the std.
       % Type help zeros to learn about this MATLAB function.

for (i=1:NUM_TRIALS)  % In MATLAB, we don't have to declare a variable before using it.
                                         % We also needn't specify our increment size --- it's always 1.
                                        % Rather than using {} a la C++, we use for () ... end;
    x=TRUE_STD * randn(1,NUM_SAMPLES)+TRUE_MEAN;  % Take a sample from our trud distribution.
    m = mean(x); % Use MATLAB's "mean" function to estimate the true mean using the data.
    s = std(x);  % Use MATLAB's "std"  function to estimate the true standard deviation using the data.
  
     % Print out a progress bar and learn how to use print statements in MATLAB
    fprintf(1,'Iteration=%d\n',i);
    fprintf(1,'\tTrue mean = %d, estimated mean = %.2f\n',TRUE_MEAN,m);  % Notice the C++-like syntax.
    fprintf(1,'\tTrue std = %d, estimated std = %.2f\n\n',TRUE_STD,s);  % Notice the C++-like syntax.

    % Put the estimates from this trial into our vector.
    mhist(1,i)=m;  % The estimate from this, the ith trial, goes in the ith location of our history vector.
    shist(1,i)=s; 
end;  % End the for loop.

subplot(2,1,1);  % Allows us to put two plots into the same figure window.  Type "help subplot."
hist(mhist);
subplot(2,1,2); % Put the history of the standard deviation into the other plot in the figure.
hist(shist);