code: def SampleDist(samples, lo=None, up=None):
      
      samples = numpy.asarray(samples)
      if lo is None:
          lo = samples.min()
      if up is None:
          up = samples.max()
  
      try:
          #construct the kernel density estimator
          dist = sample_dist(samples, lo, up)
  
      #raised by gaussian_kde if dataset is singular matrix
      except numpy.linalg.LinAlgError:
          dist = Uniform(lower=-numpy.inf, upper=numpy.inf)
  
      return dist
docs: Distribution based on samples.
  
      Estimates a distribution from the given samples by constructing a kernel
      density estimator (KDE).
  
      Args:
          samples:
              Sample values to construction of the KDE
          lo (float) : Location of lower threshold
          up (float) : Location of upper threshold
  
      Example:
          >>> distribution = chaospy.SampleDist([0, 1, 1, 1, 2])
          >>> print(distribution)
          sample_dist(lo=0, up=2)
          >>> q = numpy.linspace(0, 1, 5)
          >>> print(numpy.around(distribution.inv(q), 4))
          [0.     0.6016 1.     1.3984 2.    ]
          >>> print(numpy.around(distribution.fwd(distribution.inv(q)), 4))
          [0.   0.25 0.5  0.75 1.  ]
          >>> print(numpy.around(distribution.pdf(distribution.inv(q)), 4))
          [0.2254 0.4272 0.5135 0.4272 0.2254]
          >>> print(numpy.around(distribution.sample(4), 4)) # doctest: +SKIP
          [-0.4123  1.1645 -0.0131  1.3302]
          >>> print(numpy.around(distribution.mom(1), 4))
          1.0
          >>> print(numpy.around(distribution.ttr([1, 2, 3]), 4))
          [[1.3835 0.7983 1.1872]
           [0.2429 0.2693 0.4102]]