GetPOMDPAverageStatisticsPURPOSEAverages statistics collected after an experiment.
SYNOPSISfunction [tics SM SD]=GetPOMDPAverageStatistics(prefix,varargin)
DESCRIPTIONAverages statistics collected after an experiment. Experiments are repeated several times to get reliable statistics on the results. After each experiment, a file is generated with statistics on the results of the experiments. This function agregates those statistics computing their average value and their standard deviation. These are the values used to generate the plots in the paper. This function accepts two parameters - Prefix: First part of the name for the files with the results. All files are assumed to be in the Result directory (this part of the filename is automatically added) and filenames are supposed to be numbered consecutively. The number is added at the end of the file name, preceeded by a '-'. - n: Number of the first result file to be used. If not given 1 is assumed. This function reads as many available result files as available. The results are returned and also written down to a file with name 'Results/Prefix-result.mat'. The outputs are tics: Time at which statistics where collected SM: Mean for AV: Average value for all beliefs R: Average Discounted accumulated reward for several simulations nAlpha: Average number of alpha elements in the policy nChanges: Average number of changes of optimal action per belief from one policy to the next. SD: The standard deviation for the previous data. Example of use [tics SM SD]=GetPOMDPAverageStatistics('Test1-Figure1') See also TestRep, GetPOMDPSolutionStatistics. CROSS-REFERENCE INFORMATIONThis function calls:
SOURCE CODE0001 function [tics SM SD]=GetPOMDPAverageStatistics(prefix,varargin) 0002 % Averages statistics collected after an experiment. 0003 % 0004 % Experiments are repeated several times to get reliable statistics on 0005 % the results. After each experiment, a file is generated with statistics 0006 % on the results of the experiments. This function agregates those 0007 % statistics computing their average value and their standard deviation. 0008 % These are the values used to generate the plots in the paper. 0009 % 0010 % This function accepts two parameters 0011 % - Prefix: First part of the name for the files with the results. All 0012 % files are assumed to be in the Result directory (this part 0013 % of the filename is automatically added) and filenames are 0014 % supposed to be numbered consecutively. The number is added 0015 % at the end of the file name, preceeded by a '-'. 0016 % - n: Number of the first result file to be used. If not given 1 is 0017 % assumed. 0018 % This function reads as many available result files as available. 0019 % The results are returned and also written down to a file with name 0020 % 'Results/Prefix-result.mat'. 0021 % 0022 % The outputs are 0023 % tics: Time at which statistics where collected 0024 % SM: Mean for 0025 % AV: Average value for all beliefs 0026 % R: Average Discounted accumulated reward for several simulations 0027 % nAlpha: Average number of alpha elements in the policy 0028 % nChanges: Average number of changes of optimal action per 0029 % belief from one policy to the next. 0030 % SD: The standard deviation for the previous data. 0031 % 0032 % Example of use 0033 % [tics SM SD]=GetPOMDPAverageStatistics('Test1-Figure1') 0034 % 0035 % See also TestRep, GetPOMDPSolutionStatistics. 0036 0037 if nargin==1 0038 start=1; 0039 else 0040 start=varargin{1}; 0041 end 0042 0043 k=1; 0044 found=true; 0045 while found 0046 name=sprintf('Results/%s-%u.mat',prefix,start+k-1); 0047 fid=fopen(name); 0048 if (fid<0) 0049 found=false; 0050 else 0051 fprintf('Reading file: %s\n',name); 0052 fclose(fid); 0053 0054 C=load(name); 0055 0056 if k==1 0057 nSteps=size(C.aV,2); 0058 tics=C.tics; 0059 0060 AV=zeros(10,nSteps); 0061 R=zeros(10,nSteps); 0062 nAlpha=zeros(10,nSteps); 0063 nChanges=zeros(10,nSteps); 0064 else 0065 if nSteps~=size(C.aV,2) 0066 error('Size missmatch between different results'); 0067 end 0068 end 0069 0070 AV(k,:)=C.aV; 0071 R(k,:)=C.aR; 0072 nAlpha(k,:)=C.nA; 0073 nChanges(k,:)=C.nC; 0074 0075 k=k+1; 0076 end % end of if file can be openned 0077 end 0078 if k>1 0079 % Compute mean values 0080 r=1:(k-1); 0081 SM.AV=mean(AV(r,:),1); 0082 SD.AV=std(AV(r,:),1,1); 0083 0084 SM.R=mean(R(r,:),1); 0085 SD.R=std(R(r,:),1,1); 0086 0087 SM.nAlpha=mean(nAlpha(r,:),1); 0088 SD.nAlpha=std(nAlpha(r,:),1,1); 0089 0090 SM.nChanges=mean(nChanges(r,:),1); 0091 SD.nChanges=std(nChanges(r,:),1,1); 0092 0093 name=sprintf('Results/%s-results.mat',prefix); 0094 save(name,'tics','SM','SD'); 0095 else 0096 error('No data available to compute the average results'); 0097 end |