BOOST_FORCEINLINE static void conf_bounds(const A0& a0, A1& a1, const value_type& alpha ) { nt2::container::table<value_type> pcov = boost::proto::child_c<3>(a0); const In0& x = boost::proto::child_c<0>(a0); const In1& mu = boost::proto::child_c<1>(a0); const In2& sigma = boost::proto::child_c<2>(a0); BOOST_AUTO_TPL(z, (x-mu)/sigma); BOOST_AUTO_TPL(zvar, pcov(1,1) + (Two<value_type>()*pcov(1,2) + pcov(2,2)*z)*z); BOOST_ASSERT_MSG(nt2::globalall(nt2::is_gez(zvar)), "Covariance matrix must be positive"); value_type normz = -nt2::norminv(alpha*nt2::Half<value_type>()); BOOST_AUTO_TPL(halfwidth, normz*nt2::sqrt(zvar)/sigma); boost::proto::child_c<0>(a1) = Half<value_type>()*nt2::erfc(-Sqrt_2o_2<value_type>()*z); boost::proto::child_c<1>(a1) = Half<value_type>()*nt2::erfc(-Sqrt_2o_2<value_type>()*(z-halfwidth)); boost::proto::child_c<2>(a1) = Half<value_type>()*nt2::erfc(-Sqrt_2o_2<value_type>()*(z+halfwidth)); }
BOOST_FORCEINLINE static void conf_bounds(const A0& a0, A1& a1, const value_type& alpha ) { typedef nt2::memory::container<tag::table_, value_type, nt2::_2D> semantic; NT2_AS_TERMINAL_IN(semantic, pcov, boost::proto::child_c<3>(a0)); const In0& p = boost::proto::child_c<0>(a0); const In1& mu = boost::proto::child_c<1>(a0); const In2& sigma = boost::proto::child_c<2>(a0); auto logx0 = -Sqrt_2<A0>()*erfcinv( nt2::Two<A0>()*p); auto xvar = fma(fma(pcov(2,2), logx0, Two<value_type>()*pcov(1,2)), logx0, pcov(1,1)); BOOST_ASSERT_MSG(nt2::globalall(nt2::is_nltz(xvar)), "Covariance matrix must be positive"); value_type normz = -nt2::norminv(alpha*nt2::Half<value_type>()); auto halfwidth = normz*nt2::sqrt(xvar); boost::proto::child_c<0>(a1) = exp(fma(sigma, logx0, mu)); auto coef = exp(-halfwidth); boost::proto::child_c<1>(a1) = boost::proto::child_c<0>(a1)*coef; boost::proto::child_c<2>(a1) = boost::proto::child_c<0>(a1)/coef; }
BOOST_FORCEINLINE static void conf_bounds(const A0& a0, A1& a1, const value_type& alpha ) { typedef nt2::memory::container<tag::table_, value_type, nt2::_2D> semantic; NT2_AS_TERMINAL_IN(semantic, pcov, boost::proto::child_c<3>(a0)); const In0& x = boost::proto::child_c<0>(a0); const In1& mu = boost::proto::child_c<1>(a0); const In2& sigma = boost::proto::child_c<2>(a0); auto z = (log(if_zero_else(is_lez(x), x))-mu)/sigma; // this is [1, x0]*pcov*[1; x0] auto zvar = fma(fma(pcov(2,2), z, Two<value_type>()*pcov(1,2)), z, pcov(1,1)); BOOST_ASSERT_MSG(nt2::globalall(nt2::is_gez(zvar)), "Covariance matrix must be positive"); value_type normz = -nt2::norminv(alpha*nt2::Half<value_type>()); auto halfwidth = normz*nt2::sqrt(zvar)/sigma; boost::proto::child_c<0>(a1) = Half<value_type>()*nt2::erfc(-Sqrt_2o_2<value_type>()*z); boost::proto::child_c<1>(a1) = Half<value_type>()*nt2::erfc(-Sqrt_2o_2<value_type>()*(z-halfwidth)); boost::proto::child_c<2>(a1) = Half<value_type>()*nt2::erfc(-Sqrt_2o_2<value_type>()*(z+halfwidth)); }
void lvm_kriging( const cont_property_array_t & input, const mean_t * mean_data, const sugarbox_grid_t & grid, const ok_params_t & params, cont_property_array_t & output) { print_algo_name("LVM Kriging"); print_params(params); progress_reporter_t reporter(grid.size()); kriging_stats_t stats; typedef precalculated_covariances_t covariances_t; covariances_t pcov(cov_model_t(params), params.m_radiuses); hpgl::cont_kriging(input, grid, params, mean_data, pcov, sk_weight_calculator_t(), output, reporter, stats, mean_on_failure); write(boost::format("%1%") % stats); }