Possible bug in cplint, example multinomial.pl does not end

:- use_module(library(mcintyre)).

:- if(current_predicate(use_rendering/1)).
:- use_rendering(c3).
:- endif.
:- mc.
:- begin_lpad.

m(S,N,P):multinomial(S,N,P).

query(N,P):-
    m(S,N,P),
    S=[N1,N2|_],
    N1>N2.
    
:- end_lpad.

prob_query(N,P,Prob):-
  mc_sample(query(N,P),1000,Prob).

(ins)?- prob_query(N,P,Prob).
^CAction (h for help) ? abort

(cmd)?- mc_sample(query(N,P),1,Prob).
^CAction (h for help) ? abort

The part:

query(N,P):-
    m(S,N,P),
    S=[N1,N2|_],
    N1>N2.

When I append ‘writeln((N1,N2))’ after ‘S=[N1,N2|_]’ I’m constantly getting zeroes. So ‘N1>N2’ never gets true.

How long do I have to wait for this example?

Regards.

Hi Frank,
you should call the goal with N and P instantiated: try with

prob_query(100,[0.5,0.25,0.25],P),

In fact

  • multinomial(Var,N,P) Var (vector/list of event numbers) follows a multinomial distribution with parameters N (number of trials) and P (vector/list of event probabilities).

If you call it with N and P uninstantiated, it has no way of determining the parameters of the distribution, see the plunit test on this file

:- begin_tests(multinomial, []).

:-ensure_loaded(library(examples/multinomial)).

test(100):-
run((
prob_query(100,[0.5,0.25,0.25],P),
close_to(P,1))).

:- end_tests(multinomial).

Best
Fabrizio

2 Likes

Thank you.