Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
rok-cesnovar committed Sep 1, 2019
2 parents 4e5b0eb + 1857a38 commit 37b731b
Show file tree
Hide file tree
Showing 66 changed files with 4,330 additions and 884 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ Describe what you expect the output to be. Knowing the correct behavior is also
Provide any additional information here.

#### Current Version:
v2.19.1
v2.20.0
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pipeline {
}
}
stage('Performance') {
agent { label 'master' }
agent { label 'oldimac' }
steps {
unstash 'StanSetup'
setupCXX()
Expand Down
24 changes: 24 additions & 0 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,30 @@ Note: these are the release notes for the stan-dev/stan repository.
Further changes may arise at the interface level (stan-dev/{rstan,
pystan, cmdstan}) and math library level (stan-dev/math).

v.2.20.0 (18 July 2019)
======================================================================

New Features
------------
- Update effective sample size calculations, with a small change to the autocovariance function, to use split chains (#2774)
- Add stan::model::model_base base class and and stan::model::model_crtp static adapter class for constructing models. (#2785)
- Allow ts and t0 to be parameters, complete ode_test, and extend the integrate_ode_* stan models (#2791)
- Add the GP covariance functions to the language (primitives of some popular materns, a dot product, and the periodic) (#2758)
- Update Eigen includes to allow compilation with new plugin methods (#2754)
- Add gp kernels to language (#2739)

Bug Fixes
---------
- Multi-unit compilation of base_xhmc.hpp. (#2775)
- Declaring a size zero simplex in a Stan program will halt the program. (#2773)

Other
-----
- Defer to Eigen's copy constructor now for assignment ( faster matrix assign ) (#2784)
- Rethrow_located also takes in a string to specify the location. (#2770)
- Faster indexing (#2766)
- Fixed generator so that matrix indexing uses most efficient access strategy (#2749)

v.2.19.1 (18 Apr 2019)
======================================================================

Expand Down
2 changes: 1 addition & 1 deletion lib/stan_math
Submodule stan_math updated 1158 files
24 changes: 18 additions & 6 deletions make/tests
Original file line number Diff line number Diff line change
Expand Up @@ -123,18 +123,30 @@ test/test-model-main.cpp:

##
# Adding a test for multiple translation units. If this fails,
# a new function is probably missing an inline
# a new function is probably missing an inline.
# Templates for such test are prefixed with 'mtu_'.
##
test/integration/mtu :
mkdir -p test/integration/mtu

test/integration/mtu/%_1.cpp : src/test/integration/mtu/%.cpp test/integration/mtu
cp $< $@
test/integration/mtu/%_2.cpp : src/test/integration/mtu/%.cpp test/integration/mtu
cp $< $@

ifneq ($(OS),Windows_NT)
test/unit/multiple_translation_units%.o : CXXFLAGS += -fPIC
test/integration/mtu/%.o : CXXFLAGS += -fPIC
endif
test/unit/multiple_translation_units%.o : CXXFLAGS += -pipe
test/unit/libmultiple.so : LDFLAGS += -shared
test/integration/mtu/%.o : O = 0
test/integration/mtu/%.o : %.cpp
$(COMPILE.cpp) -pipe -o $(DEV_NULL) -include $^

test/integration/libmtu_%.so : LDFLAGS += -shared

test/unit/libmultiple.so : test/unit/multiple_translation_units1.o test/unit/multiple_translation_units2.o $(MPI_TARGETS)
test/integration/libmtu_%.so : test/integration/mtu/%_1.o test/integration/mtu/%_2.o $(MPI_TARGETS)
$(LINK.cpp) $^ $(LDLIBS) $(OUTPUT_OPTION)

test/unit/multiple_translation_units_test$(EXE) : test/unit/libmultiple.so
test/integration/multiple_translation_units_test$(EXE) : test/integration/libmtu_model.so test/integration/libmtu_mcmc.so


############################################################
Expand Down
2 changes: 1 addition & 1 deletion src/doxygen/doxygen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = "Stan"
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2.19.1
PROJECT_NUMBER = 2.20.0

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
123 changes: 123 additions & 0 deletions src/stan/analyze/mcmc/autocovariance.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#ifndef STAN_ANALYZE_MCMC_AUTOCOVARIANCE_HPP
#define STAN_ANALYZE_MCMC_AUTOCOVARIANCE_HPP

#include <stan/math/prim/mat/fun/Eigen.hpp>
#include <stan/math/prim/mat.hpp>
#include <unsupported/Eigen/FFT>
#include <complex>
#include <vector>

namespace stan {
namespace analyze {

/**
* Write autocorrelation estimates for every lag for the specified
* input sequence into the specified result using the specified FFT
* engine. Normalizes lag-k autocorrelation estimators by N instead
* of (N - k), yielding biased but more stable estimators as
* discussed in Geyer (1992); see
* https://projecteuclid.org/euclid.ss/1177011137. The return vector
* will be resized to the same length as the input sequence with
* lags given by array index.
*
* <p>The implementation involves a fast Fourier transform,
* followed by a normalization, followed by an inverse transform.
*
* <p>An FFT engine can be created for reuse for type double with:
*
* <pre>
* Eigen::FFT<double> fft;
* </pre>
*
* @tparam T Scalar type.
* @param y Input sequence.
* @param ac Autocorrelations.
* @param fft FFT engine instance.
*/
template <typename T, typename DerivedA, typename DerivedB>
void autocorrelation(const Eigen::MatrixBase<DerivedA>& y,
Eigen::MatrixBase<DerivedB>& ac, Eigen::FFT<T>& fft) {
size_t N = y.size();
size_t M = math::internal::fft_next_good_size(N);
size_t Mt2 = 2 * M;

// centered_signal = y-mean(y) followed by N zeros
Eigen::Matrix<T, Eigen::Dynamic, 1> centered_signal(Mt2);
centered_signal.setZero();
centered_signal.head(N) = y.array() - y.mean();

Eigen::Matrix<std::complex<T>, Eigen::Dynamic, 1> freqvec(Mt2);
fft.fwd(freqvec, centered_signal);
// cwiseAbs2 == norm
freqvec = freqvec.cwiseAbs2();

Eigen::Matrix<std::complex<T>, Eigen::Dynamic, 1> ac_tmp(Mt2);
fft.inv(ac_tmp, freqvec);

// use "biased" estimate as recommended by Geyer (1992)
ac = ac_tmp.head(N).real().array() / (N * N * 2);
ac /= ac(0);
}

/**
* Write autocovariance estimates for every lag for the specified
* input sequence into the specified result using the specified FFT
* engine. Normalizes lag-k autocovariance estimators by N instead
* of (N - k), yielding biased but more stable estimators as
* discussed in Geyer (1992); see
* https://projecteuclid.org/euclid.ss/1177011137. The return vector
* will be resized to the same length as the input sequence with
* lags given by array index.
*
* <p>The implementation involves a fast Fourier transform,
* followed by a normalization, followed by an inverse transform.
*
* <p>This method is just a light wrapper around the three-argument
* autocovariance function
*
* @tparam T Scalar type.
* @param y Input sequence.
* @param acov Autocovariances.
*/
template <typename T, typename DerivedA, typename DerivedB>
void autocovariance(const Eigen::MatrixBase<DerivedA>& y,
Eigen::MatrixBase<DerivedB>& acov) {
Eigen::FFT<T> fft;
autocorrelation(y, acov, fft);
acov = acov.array() * (y.array() - y.mean()).square().sum() / y.size();
}

/**
* Write autocovariance estimates for every lag for the specified
* input sequence into the specified result using the specified FFT
* engine. Normalizes lag-k autocovariance estimators by N instead
* of (N - k), yielding biased but more stable estimators as
* discussed in Geyer (1992); see
* https://projecteuclid.org/euclid.ss/1177011137. The return vector
* will be resized to the same length as the input sequence with
* lags given by array index.
*
* <p>The implementation involves a fast Fourier transform,
* followed by a normalization, followed by an inverse transform.
*
* <p>This method is just a light wrapper around the three-argument
* autocovariance function
*
* @tparam T Scalar type.
* @param y Input sequence.
* @param acov Autocovariances.
*/
template <typename T>
void autocovariance(const std::vector<T>& y, std::vector<T>& acov) {
size_t N = y.size();
acov.resize(N);

const Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, 1>> y_map(&y[0], N);
Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, 1> > acov_map(&acov[0], N);
autocovariance<T>(y_map, acov_map);
}

} // namespace analyze
} // namespace stan

# endif
Loading

0 comments on commit 37b731b

Please sign in to comment.