code: def empirical_frechet_var_bubble(
      n_samples, theta, dim, n_expectation=1000
  ):
      """Variance of the empirical Fréchet mean for a bubble distribution.
  
      Draw n_sampless from a bubble distribution, computes its empirical
      Fréchet mean and the square distance to the asymptotic mean. This
      is repeated n_expectation times to compute an approximation of its
      expectation (i.e. its variance) by sampling.
  
      The bubble distribution is an isotropic distributions on a Riemannian
      hyper sub-sphere of radius 0 < theta < Pi around the north pole of the
      sphere of dimension dim.
  
      Parameters
      ----------
      n_samples : int
          Number of samples to draw.
      theta: float
          Radius of the bubble distribution.
      dim : int
          Dimension of the sphere (embedded in R^{dim+1}).
      n_expectation: int, optional (defaults to 1000)
          Number of computations for approximating the expectation.
  
      Returns
      -------
      tuple (variance, std-dev on the computed variance)
      """
      if dim <= 1:
          raise ValueError(
              "Dim > 1 needed to draw a uniform sample on sub-sphere."
          )
      var = []
      sphere = Hypersphere(dim=dim)
      bubble = Hypersphere(dim=dim - 1)
  
      north_pole = gs.zeros(dim + 1)
      north_pole[dim] = 1.0
      for _ in range(n_expectation):
          # Sample n points from the uniform distribution on a sub-sphere
          # of radius theta (i.e cos(theta) in ambient space)
          # TODO (nina): Add this code as a method of hypersphere
          last_col = gs.cos(theta) * gs.ones(n_samples)
          last_col = last_col[:, None] if (n_samples > 1) else last_col
  
          directions = bubble.random_uniform(n_samples)
          rest_col = gs.sin(theta) * directions
          data = gs.concatenate([rest_col, last_col], axis=-1)
  
          estimator = FrechetMean(sphere, method="adaptive").set(
              max_iter=32, init_point=north_pole
          )
          if n_samples == 1:
              data = gs.expand_dims(data, 0)
  
          estimator.fit(data)
          current_mean = estimator.estimate_
          var.append(
              sphere.metric.squared_dist(north_pole, current_mean)
          )
      return gs.mean(var), 2 * gs.std(var) / gs.sqrt(n_expectation)
  
file_path: geomstats/examples/empirical_frechet_mean_uncertainty_sn.py
imports: import logging
  import matplotlib.pyplot
  import geomstats.backend
  from geomstats.geometry.hypersphere import Hypersphere
  from geomstats.learning.frechet_mean import FrechetMean
label_desc: Use image node_id 1 for calling a global function with example usage: empirical_frechet_var_bubble(n_samples, theta, dim, n_expectation) and returns: gs,  unknown