//Session file SetLogFile("fixpnts.log": Overwrite := true); // fixed point counter numFP := function(sd); s := 0; n := #sd; for i := 1 to n do if i eq sd[i] then s := s+1; end if; end for; return s; end function; //define deck, set up "shuffle group" udeck := [1,2,3,4,5]; G := SymmetricGroup(5); // remember that udeck^(pi^(-1)) is the deck shuffled by pi //average number of fixed points nfp := 0; for pi in G do nfp := nfp+numFP(udeck^(pi^(-1))); end for; avgFP := nfp/#G; print "avgFP = ",avgFP; //probability of a fixed point fp := 0; for pi in G do if numFP(udeck^(pi^(-1))) gt 0 then fp := fp+1; end if; end for; probFP := fp/#G; print "probFP = ",probFP; //End Session UnsetLogFile();