BRMLtoolbox pot() function not defined.

I am working with the BRMLtoolbox for MATLAB. You can download it in the link provided and just run setup.m file.

This is the structure of the BRMLtoolbox:

I was trying to work with one of the Demo Exercises, as described in the book Bayesian Reasoning and Machine Learning at page 35 of the pdf. For simplicity, I've taken a screenshot of the page:

Now, you don't need to know anything about the underlying mathematics to help me solve this issue. I am new to MATLAB (started learning it today, coming from Python). I started going through the demoClouseau.m file contained in the DemosExercises folder. This is what it looks like:

      function demoClouseau
      %DEMOCLOUSEAU inspector clouseau example
      import brml.*
      butler=3; maid=2; knife=1; % Variable order is arbitary
      murderer=1; notmurderer=2; used=1; notused=2; % define states, starting from 1.
      % The following definitions of variable are not necessary for computation,
      % but are useful for displaying table entries:
      variable(butler).name='butler'; variable(butler).domain = {'murderer','not murderer'};
      variable(maid).name='maid'; variable(maid).domain ={'murderer','not murderer'};
      variable(knife).name='knife'; variable(knife).domain={'used','not used'};
      % Three potential since p(butler,maid,knife)=p(knife|butler,maid)p(butler)p(maid).
      % potential numbering is arbitary
      pot(butler)=array;
      pot(butler).variables=butler;
      pot(butler).table(murderer)=0.6;
      pot(butler).table(notmurderer)=0.4;
      pot(maid)=array;
      pot(maid).variables=maid;
      pot(maid).table(murderer)=0.2;
      pot(maid).table(notmurderer)=0.8;
      pot(knife)=array;
      pot(knife).variables=[knife,butler,maid]; % define array below using this variable order
      pot(knife).table(used, notmurderer, notmurderer)=0.3;  
      pot(knife).table(used, notmurderer, murderer)   =0.2;
      pot(knife).table(used, murderer,    notmurderer)=0.6;
      pot(knife).table(used, murderer,    murderer)   =0.1;
      pot(knife).table(notused,:,:)=1-pot(knife).table(used,:,:); % due to normalisation
      jointpot = multpots(pot); % joint distribution
      drawNet(dag(pot),variable);
      disp('p(butler|knife=used):')
      disptable(condpot(setpot(jointpot,knife,used),butler),variable);

Now, I can run this script no problem and this is the output of it:

And this is the plot that comes out:

So it seems to be running no problem! However, if I just use the command line and type

    import brml.*
    pot(1)

As suggested in the book, I get an error! `Undefined function or variable 'pot'.` What is pot? Is it a variable? Is it a function? Is it a class? I thought it was a class defined in the BRMLtoolbox, but I cannot find it.

I tried debugging the code by putting a breakpoint as such:

And there are some weird things happening:

  • First of all, the code did not break, I did not get the error above.
  • Secondly, if Now I write `pot` in the Console, I get an answer!

So somehow, pot here works, although it is not defined in the code!

What is going on? I cannot even understand the syntax, it seems to kind of define `pot` on the fly with the pot(butler) = array statement, but I can't quite figure it out.

Answers (1)

Vyas Raina
Vyas Raina on 28 Jul 2020
Hey, don't know if this is relevant anymore to you, but it may be useful for other viewers:
"pot" has nothing to do with the BRML toolkit. You could have very well done blob(X) = array; It is just another way of defining an object in matlab that takes X as an argument...
For others also interested in the Clouseau Problem, there is a good explanation at:

Categories

Asked:

on 30 Jul 2018

Answered:

on 28 Jul 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!