//Session file SetLogFile("fixpntsR.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", sample size n := 10; udeck := [1..n]; G := SymmetricGroup(n); numsamp :=5000; // remember that udeck^(pi^(-1)) is the deck shuffled by pi //average number of fixed points nfp := 0; for i := 1 to numsamp do pi := Random(G); nfp := nfp+numFP(udeck^(pi^(-1))); end for; avgFP := nfp/numsamp; print "avgFP = ",avgFP; //probability of a fixed point fp := 0; for i := 1 to numsamp do pi := Random(G); if numFP(udeck^(pi^(-1))) gt 0 then fp := fp+1; end if; end for; probFP := fp/numsamp; print "probFP = ",probFP; //End Session UnsetLogFile();