You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: DEM_demo_MDP_maze.m
    path of file: ./repos/spm12/toolbox/DEM
    
    the code of the file until where you have to start completion: function MDP = DEM_demo_MDP_maze
% Demo of active inference for epistemic foraging
%__________________________________________________________________________
%
% This routine uses the Markov decision process formulation of active
% inference (with variational Bayes) to model foraging for information in a
% three arm maze.  This demo illustrates variational free energy
% minimisation in the context of Markov decision processes, where the agent
% is equipped with prior beliefs tha
    
function of preference
%==========================================================================
spm_figure('GetWin','Figure 2'); clf
MDP.plot = 0;
MDP.N    = 4;

n     = 128;                              % number of simulated trials
c     = linspace(0,1,6);
d     = kron(ones(4,1),[0; 0; 1; 0]);
for i = 1:length(c)
    
    % preference
    %----------------------------------------------------------------------
    MDP.C = spm_softmax(kron(ones(4,1),[0; 0; c(i); -c(i)]));
    
    
    % simulate trials and record outcomes
    %----------------------------------------------------------------------
    for j = 1:n
        
        % randomise reward
        %------------------------------------------------------------------
        s       = rand > 1/2;
        MDP.S   = kron([1 0 0 0],[s ~s])';
        
        
        % inverst under different schemes
        %------------------------------------------------------------------
        MDP     = spm_MDP_game(MDP,'FE');
        FE(j,i) = d'*MDP.O(:,end