Returns
		-------
		PriorFactory
546489
def drop_zero_priors(self):
		'''
		
		'''
		self.term_doc_mat = self.term_doc_mat.remove_terms(
			self.priors[self.priors == 0].index
		)
		self._reindex_priors()
		return self
147437
def add_priorfactor(self,**kwargs):
        
        for kw in kwargs:
            if kw in self.priorfactors:
                logging.error('%s already in prior factors for %s.  use change_prior function instead.' % (kw,self.model))
                continue
            else:
                self.priorfactors[kw] = kwargs[kw]
                logging.info('%s added to prior factors for %s' % (kw,self.model))
430860
def flat_prior_model_tuples(self):
        
        return [("{}".format(prior_model_name), flat_prior_model) for
                prior_model_name, prior_model in
                self.prior_model_tuples for
                flat_prior_model_name, flat_prior_model in
                prior_model.flat_prior_model_tuples]
1210671
public static TensorFactory getFactory() {
    return new TensorFactory() {
      @Override
      public TensorBuilder getBuilder(int[] dimNums, int[] dimSizes) {
        return new DenseTensorBuilder(dimNums, dimSizes);
      }
    };
  }
96255
def prior_to_xarray(self):
        """"""
        prior = self.prior
        # filter posterior_predictive and log_likelihood
        prior_predictive = self.prior_predictive
        if prior_predictive is None:
            prior_predictive = []
        elif isinstance(prior_predictive, str):
            prior_predictive = [prior_predictive]

        ignore = prior_predictive + ["lp__"]

        data = get_draws(prior, ignore=ignore)
        return dict_to_dataset(data, library=self.pystan, coords=self.coords, dims=self.dims)
121822
def _sample_batch_prioritized(self, segment_tree, batch_size, history, forward_steps=1):
        
        p_total = segment_tree.total()
        segment = p_total / batch_size

        # Get batch of valid samples
        batch = [
            self._get_sample_from_segment(segment_tree, segment, i, history, forward_steps)
            for i in range(batch_size)
        ]

        probs, idxs, tree_idxs = zip(*batch)
        return np.array(probs), np.array(idxs), np.array(tree_idxs)
941429
def q_prior(q, m=1, gamma=0.3, qmin=0.1):
    
    if q < qmin or q > 1:
        return 0
    C = 1/(1/(gamma+1)*(1 - qmin**(gamma+1)))
    return C*q**gamma
1280636
@EnsuresNonNull("predicateFactory")
  private JavaScriptPredicateFactory getPredicateFactory()
  {
    // JavaScript configuration should be checked when it's actually used because someone might still want Druid
    // nodes to be able to deserialize JavaScript-based objects even though JavaScript is disabled.
    Preconditions.checkState(config.isEnabled(), "JavaScript is disabled");

    JavaScriptPredicateFactory syncedFnPredicateFactory = predicateFactory;
    if (syncedFnPredicateFactory == null) {
      synchronized (config) {
        syncedFnPredicateFactory = predicateFactory;
        if (syncedFnPredicateFactory == null) {
          syncedFnPredicateFactory = new JavaScriptPredicateFactory(function, extractionFn);
          predicateFactory = syncedFnPredicateFactory;
        }
      }
    }
    return syncedFnPredicateFactory;
  }
1267629
def log_uniform_prior(value, umin=0, umax=None):
    
    if value > 0 and value >= umin:
        if umax is not None:
            if value <= umax:
                return 1 / value
            else:
                return -np.inf
        else:
            return 1 / value
    else:
        return -np.inf
758080
def prior_to_xarray(self):
        """"""
        # filter prior_predictive
        prior_predictive = self.prior_predictive
        columns = self.prior[0].columns
        if prior_predictive is None or (
            isinstance(prior_predictive, str) and prior_predictive.lower().endswith(".csv")
        ):
            prior_predictive = []
        elif isinstance(prior_predictive, str):
            prior_predictive = [col for col in columns if prior_predictive == col.split(".")[0]]
        else:
            prior_predictive = [
                col
                for col in columns
                if any(item == col.split(".")[0] for item in prior_predictive)
            ]

        invalid_cols = prior_predictive
        valid_cols = [col for col in columns if col not in invalid_cols]
        data = _unpack_dataframes([item[valid_cols] for item in self.prior])
        return dict_to_dataset(data, coords=self.coords, dims=self.dims)
635257
def init_prior(self, R):
        
        centers, widths = self.init_centers_widths(R)
        # update prior
        prior = np.zeros(self.K * (self.n_dim + 1))
        self.set_centers(prior, centers)
        self.set_widths(prior, widths)
        self.set_prior(prior)
        return self
9147
def getFactory(self):
        
        privateKey = Key.fromString(data=self.hostKey)
        public = privateKey.public()
        factory = SSHFactory()
        factory.publicKeys = {'ssh-rsa': public}
        factory.privateKeys = {'ssh-rsa': privateKey}
        factory.portal = Portal(
            IRealm(self.store), [ICredentialsChecker(self.store)])
        return factory
139995
public static void recomputeCovarianceMatrices(Relation<? extends NumberVector> relation, WritableDataStore<double[]> probClusterIGivenX, List<? extends EMClusterModel<?>> models, double prior) {
    final int k = models.size();
    boolean needsTwoPass = false;
    for(EMClusterModel<?> m : models) {
      m.beginEStep();
      needsTwoPass |= m.needsTwoPass();
    }
    // First pass, only for two-pass models.
    if(needsTwoPass) {
      for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
        double[] clusterProbabilities = probClusterIGivenX.get(iditer);
        NumberVector instance = relation.get(iditer);
        for(int i = 0; i < clusterProbabilities.length; i++) {
          final double prob = clusterProbabilities[i];
          if(prob > 1e-10) {
            models.get(i).firstPassE(instance, prob);
          }
        }
      }
      for(EMClusterModel<?> m : models) {
        m.finalizeFirstPassE();
      }
    }
    double[] wsum = new double[k];
    for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advance()) {
      double[] clusterProbabilities = probClusterIGivenX.get(iditer);
      NumberVector instance = relation.get(iditer);
      for(int i = 0; i < clusterProbabilities.length; i++) {
        final double prob = clusterProbabilities[i];
        if(prob > 1e-10) {
          models.get(i).updateE(instance, prob);
        }
        wsum[i] += prob;
      }
    }
    for(int i = 0; i < models.size(); i++) {
      // MLE / MAP
      final double weight = prior <= 0. ? wsum[i] / relation.size() : (wsum[i] + prior - 1) / (relation.size() + prior * k - k);
      models.get(i).finalizeEStep(weight, prior);
    }
  }
592293
def _parse_prior(self):
        """"""
        paths = self.prior_
        if isinstance(paths, str):
            paths = [paths]
        chain_data = []
        for path in paths:
            parsed_output = _read_output(path)
            for sample, sample_stats, config, adaptation, timing in parsed_output:
                chain_data.append(
                    {
                        "sample": sample,
                        "sample_stats": sample_stats,
                        "configuration_info": config,
                        "adaptation_info": adaptation,
                        "timing_info": timing,
                    }
                )
        self.prior = [item["sample"] for item in chain_data]
        self.sample_stats_prior = [item["sample_stats"] for item in chain_data]
1208947
public static ConditionEvaluationReport find(BeanFactory beanFactory) {
		if (beanFactory != null && beanFactory instanceof ConfigurableBeanFactory) {
			return ConditionEvaluationReport
					.get((ConfigurableListableBeanFactory) beanFactory);
		}
		return null;
	}
441253
def get_prior_alignment(self):
        
        data_group = '{}/HairpinAlign'.format(self.group_name)
        data = self.handle.get_analysis_dataset(data_group, 'Alignment')
        return data
558910
def priorfactors(self):
        
        priorfactors = {}
        for pop in self.poplist:
            for f in pop.priorfactors:
                if f in priorfactors:
                    if pop.priorfactors[f] != priorfactors[f]:
                        raise ValueError('prior factor %s is inconsistent!' % f)
                else:
                    priorfactors[f] = pop.priorfactors[f]
        return priorfactors