#C16.txt, Dr. Z. ExpMath, March 25, 2019 Help:=proc(): print(` GuessWhoS(x,N), ManyGWS(N,K,t), GuessWhoC(x,N) , SEnt(P) `): print(`Profile(n,k), ABTP(N,k) `): end: #Simulating a stupid guess who game with a nunmber from 0 to N GuessWhoS:=proc(x,N) local co,i: co:=0: for i from 0 to N do #print(`Is the number equal to`, i): co:=co+1: if x=i then RETURN(co): fi: od: FAIL: end: #ManyGHS(N,K,t): the prob. generating function using variable t #fof K Guess who games, followed by the average and s.d. ManyGWS:=proc(N,K,t) local ra,i,f,mu,sig,f1: ra:=rand(0..N): f:=add(t^GuessWhoS(ra(),N),i=1..K)/K: mu:=subs(t=1,diff(f,t)): f1:=f/t^mu: sig:= sqrt(subs(t=1,diff(t*diff(f1,t),t))): [evalf([mu,sig]),sort(evalf(f))]: end: #Simulating a clever guess who game with a nunmber from 0 to N GuessWhoC:=proc(x,N) local co,L,U,U0: L:=0: U:=trunc((N-1)/2): co:=0: while L=L and x<=U then U:=trunc((U+L)/2): else U0:=U: U:=trunc(U+(U-L)/2): L:=U0+1: fi: od: co: end: #SEent(P): The (Shannon) amount of information in bits of the discere prob. distribution P SEnt:=proc(P) local i: if not (type(P,list) and min(op(P))>0 and convert(P,`+`)=1) then print(`bad input`): RETURN(FAIL): fi: -add(P[i]*log[2](P[i]),i=1..nops(P)): end: #[[Name,[DescriptiveFeature1, ..., DescriptiveFeature],targetFeature] , ...] #Profile(n,k): inputs a positive integer n and k outputs #a list of 0,1 of length k whose i-th item is "Is n divisible by prime[i]" for i from 1 to k #For example #Profile(10,3) should output [1,0,1] Profile:=proc(n,k) local i: subs({true=1, false=0},[ seq(evalb(n mod ithprime(i)=0),i=1..k)]): end: #Inputs a positive integer N and pos. integer k outputs an ABT #for the data generated from them using the k descriptive features #is it divisible by the k-th prime ABTP:=proc(N,k) local n: [ seq([n,Profile(n,k), isprime(n)],n=1..N)]: end: