yt.data_objects.derived_quantities.WeightedVariance — The yt Project 3.2-dev documentation

# yt.data_objects.derived_quantities.WeightedVariance

class `yt.data_objects.derived_quantities.` `WeightedVariance`(data_source)

  Calculates the weighted variance and weighted mean for a field or list of fields.

  Where f is the field, w is the weight, and <f_w> is the weighted mean, the weighted variance is Sum_i( (f_i - <f_w>)^2 * w_i ) / Sum_i(w_i).

  Parameters: | fields : field or list of fields The field or fields of which the variance and mean values are to be calculated. weight : field The weight field.

  Examples

      >>> ds = load("IsolatedGalaxy/galaxy0030/galaxy0030")
      >>> ad = ds.all_data()
      >>> print ad.quantities.weighted_variance([("gas", "density"),
      ...                                        ("gas", "temperature")],
      ...                                       ("gas", "cell_mass"))

  Attributes

  Methods