I am reading the source code of MAGeCK 0.5.9.5 which is a popular software for analyzing CRISPR knockout screen data. In its mageckMathFunc.py, it calculates "mean" and "variance" as follows:
def mmedian(lst):
sortedLst = sorted(lst)
lstLen = len(lst)
if lstLen==0:
return 0.0
index = (lstLen - 1) // 2
if (lstLen % 2):
return sortedLst[index]
else:
return (sortedLst[index] + sortedLst[index + 1])/2.0
def getMeans(matt):
meanvalue=[mmedian(v) for v in matt]
return meanvalue
def getVars(matt):
matt=list(matt)
meanvalue=getMeans(matt)
varvalue=[ sum([ (kj-meanvalue[i])*(kj-meanvalue[i]) for kj in matt[i] ] )/max(float(len(matt[i]))-1,1.0) for i in range(len(meanvalue))]
return varvalue
Then it uses their return values to use as sample mean and sample variance extensively throughout the code. Apparently, they are not the conventional mean and variance based on simple arithmetic mean. Is there a name for this type of "sample mean" and "sample variance" based on median? Under what circumstances should we use them instead of the conventional ones? Thank you very much in advance.