::std::pair<ValueT,ValueT> confidence_interval_mean(SampleT const& sample, ValueT s, ValueT level)
{
	ValueT n = count(sample);

	normal<ValueT> dist;
	ValueT z = dist.quantile((1+level)/ValueT(2));

	ValueT m = mean(sample);
	ValueT h = z*s/::std::sqrt(n);

	return ::std::make_pair(m-h, m+h);
}
::std::pair<ValueT,ValueT> confidence_interval_mean(SampleT const& sample, ValueT level)
{
	ValueT n = count(sample);

	students_t<ValueT> dist(n-1);
	ValueT t = dist.quantile((1+level)/ValueT(2));

	ValueT s = standard_deviation(sample);
	ValueT m = mean(sample);
	ValueT h = t*s/::std::sqrt(n);

	return ::std::make_pair(m-h, m+h);
}
Example #3
0
      /*!
       * Initializes value to \c ValueT(x) and derivative array is empty
       */
      DFad(const ScalarT& x) : 
	Expr< GeneralFad< ValueT,DynamicStorage<ValueT> > >(ValueT(x)) {}
Example #4
0
      //! Assignment operator with constant right-hand-side
      DFad& operator=(const ScalarT& val) {
	GeneralFad< ValueT,DynamicStorage<ValueT> >::operator=(ValueT(val));
	return *this;
      }
 /*!
  * Initializes value to \c ValueT(x) and derivative array is empty
  */
 DMFad(const ScalarT& x) :
     Expr< GeneralFad< ValueT,MemPoolStorage<ValueT> > >(ValueT(x)) {}
 //! Assignment operator with constant right-hand-side
 DMFad& operator=(const ScalarT& val) {
     GeneralFad< ValueT,MemPoolStorage<ValueT> >::operator=(ValueT(val));
     return *this;
 }
Example #7
0
 SafeHash() : defaultValue(ValueT()) {}
Example #8
0
Result FunctionBetween (const IFormulaContext * context, const class Formula & termSource, unsigned * pindex) {
	Result ret;
	ret.type = RESULT_TYPE_SCALAR;

	--(*pindex);
	Result v2 = termSource.EvaluateSubexpression(context, pindex);
	if(v2.code != RESULT_CODE_OK)
		return v2;

	--(*pindex);
	Result v1 = termSource.EvaluateSubexpression(context, pindex);
	if(v1.code != RESULT_CODE_OK)
		return v1;

	--(*pindex);
	Result t = termSource.EvaluateSubexpression(context, pindex);
	if(t.code != RESULT_CODE_OK)
		return t;

	ret.payload.num.value = (v1.payload.num.value < t.payload.num.value && t.payload.num.value < v2.payload.num.value) ? ValueT(1.0) : ValueT(0.0);
	ret.code = RESULT_CODE_OK;
	return ret;
}