HP Forums

Full Version: (48G) 48G , 49G & 50G: Entropy calculation programme
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
A programme for the 48G ( and 49G, 49G+, 50G - no need to change anything) to calculate the entropy of a system given a list of the state probabilities - if the sum of probabilities is < 1 the programme adds one state with the missing probability.

eg For input

{ .1 .2 .3 }

the programme returns

{ .1 .2 .3}
:Extra-Prob: .4
:Ent: 1.84643934468

Code:
::
  CK1&Dispatch
  BINT5
  ::
    DUP
    DUPINCOMP
    DUP#0=case
    SETTYPEERR
    %0
    SWAP
    ZERO_DO
    SWAP
    DUPTYPEREAL?
    ::
      NcaseTYPEERR
      %+
    ;
    LOOP
    DUP
    %1
    %>
    caseSIZEERR
    %1
    SWAP
    %-
    DUPROT
    INNERCOMP
    %0
    SWAP1+
    ZERO_DO
    SWAP
    DUP%0=
    ITE
    DROP
    ::
      DUP
      %LN
      %2
      %LN
      %/
      %*
      %+
    ;
    LOOP
    %CHS
    '   
    ID Ent
    ID>TAG
    SWAP
    DUP%0=
    caseDROP
    '
    ID Extra-Prob
    ID>TAG
    SWAP
  ;
;
Reference URL's