What is the meaning of using median instead of mean to calculate sample variance? 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.

Comment: I am not sure of the formula for your variance estimate or the purpose in using something other than
the usual sample variance $S^2 = \frac{1}{n-1}\sum_{i=1}^n (X_i - \bar X)^2$, where $\bar X$ is the sample mean.
Perhaps this page linked in the margin is relevant.
Also, perhaps consider the function mad for Median Absolute Deviation in R. Roughly, it is the median of the absolute deviations from the sample median.
MAD has been proposed as a robust measure of variability.
For a normal sample, when mad is multiplied by $1.4826.$ (the default in R), its expected value is the normal standard deviation $\sigma.$
set.seed(1234)
x = rnorm(10000, 100, 15)
mad(x)
[1] 14.79603  # aprx 15
sd(x)
[1] 14.81294

