Post Reply 
(48G) 48G , 49G & 50G: Entropy calculation programme
06-04-2015, 06:47 PM (This post was last modified: 06-15-2017 01:51 PM by Gene.)
Post: #1
(48G) 48G , 49G & 50G: Entropy calculation programme
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
  ;
;
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)