void InfiniteDimensionalMCMCSampler::_update_moments() { // Increment the current iteration number and update the running mean and // variance. this->_iteration += 1; // Make _delta contain the difference from the mean this->_delta->zero(); this->_delta->add(1.0, *(this->current_physical_state)); this->_delta->add(-1.0, *(this->current_physical_mean)); // Scale _delta to update the mean field this->current_physical_mean->add(1.0 / this->iteration(), *(this->_delta)); // Update running sum-of-squares boost::shared_ptr<FunctionBase> temp_ptr(this->_delta->zero_clone()); // LibMeshFunction & temp = static_cast<LibMeshFunction &>(*temp_ptr); temp_ptr->pointwise_mult(*(this->_delta), *(this->current_physical_state)); this->_M2->add(1.0, *temp_ptr); temp_ptr->pointwise_mult(*(this->_delta), *(this->current_physical_mean)); this->_M2->add(-1.0, *temp_ptr); if (this->iteration() > 1) { this->current_physical_var->zero(); this->current_physical_var->add(1.0 / (this->iteration() - 1), *(this->_M2)); } // Update acceptance rate double delta_acc = this->acc_prob() - this->avg_acc_prob(); this->_avg_acc_prob += delta_acc / this->iteration(); }
/// \brief An assignment operator which uses the clone method of cloneable_pointee_type clone_ptr & operator=(const clone_ptr &arg_clone_ptr ///< TODOCUMENT ) { // Check for self-assignment if ( this != &arg_clone_ptr ) { std::unique_ptr<cloneable_pointee_type> temp_ptr( arg_clone_ptr->clone() ); *this = temp_ptr; assert( typeid( *ptr.get() ) == typeid( *arg_clone_ptr.get() ) ); // Check the dynamic type returned by clone() } return *this; }