> Sorry, this looks like it should work:
>
> % Out is 10 - int(log(rand(9)+1) / log(10)*10);
> logDist (Max,Out):-
> M2 is (Max)-1,
> R is random(M2),
> prolog_eval(log(R), X),
> N is (X)+1,
> prolog_eval(int(N),LeftSide),
> Z is prolog_eval(log(Max)*Max,RightSide),
> Pre is (LeftSide)/RightSide,
> Out is (10)-Pre.
Lee, your commented out line was *almost* right - its just a question
of knowing the right names for the pop11 built in functions:
?- X is 10 - intof(log(random0(9)+1)/log(10)*10).
Check out (pop11) help random and help intof.
Roger
|