From 5831c78c540e782fbbbe0eb14f98206358c2d1b4 Mon Sep 17 00:00:00 2001 From: Brian Lau Date: Sun, 14 May 2017 23:47:41 +0200 Subject: [PATCH] Squashed commits: [77d2742] BF: catch for situation where legacy rng is active (issue #32) [fcd3c0c] Bump StanModel version [8cfc934] correct license --- Examples/variational.m | 4 ++-- LICENSE.txt | 45 ++++++++++++++++++++++-------------------- StanModel.m | 2 +- mcmc.m | 10 +++++++--- 4 files changed, 34 insertions(+), 27 deletions(-) diff --git a/Examples/variational.m b/Examples/variational.m index d955db1..52fdcbb 100644 --- a/Examples/variational.m +++ b/Examples/variational.m @@ -37,8 +37,8 @@ % 1 chains, each with iter=2000, warmup=0, thin=1; % post-warmup draws per chain=2000, total post-warmup draws=2000. % -% mean sd 2.5% 25% 50% 75% 97.5% -% mu 7.75 4.63 -1.46 4.78 7.73 10.83 16.88 +% mean sd 2.5% 25% 50% 75% 97.5% +% mu 7.75 4.63 -1.46 4.78 7.73 10.83 16.88 % tau 4.61 3.73 0.87 2.17 3.61 5.83 14.79 % eta[1] 0.34 0.99 -1.70 -0.33 0.37 0.99 2.26 % eta[2] -0.10 0.87 -1.74 -0.68 -0.11 0.48 1.59 diff --git a/LICENSE.txt b/LICENSE.txt index 8fca0d5..be55011 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,24 +1,27 @@ -Copyright (c) 2015, Brian Lau +Copyright (c) 2017, Brian Lau All rights reserved. -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/StanModel.m b/StanModel.m index aa9fec6..0d5b846 100644 --- a/StanModel.m +++ b/StanModel.m @@ -157,7 +157,7 @@ model_name_ end properties(SetAccess = protected) - version = '0.6.1'; + version = '0.7.0'; end methods diff --git a/mcmc.m b/mcmc.m index ba2bd1f..70423c7 100644 --- a/mcmc.m +++ b/mcmc.m @@ -26,7 +26,7 @@ rng_state % This is for the Matlab RNG end properties(GetAccess = public, SetAccess = protected) - version = '0.3.1'; + version = '0.3.2'; end methods @@ -70,7 +70,6 @@ function ind = get.permute_index(self) % https://github.com/stan-dev/pystan/pull/26 - % TODO : cache this if ~isempty(self.samples) curr = rng; rng(self.rng_state); % state at object construction @@ -87,13 +86,18 @@ function set.rng_state(self,r) if nargin == 2 if (isstruct(r)) || (isscalar(r) && (r>=0)) + curr = rng; + if strcmp(curr.Type,'Legacy') + rng('default'); + end rng(r); self.rng_state = rng; else error('mcmc:rng:InputFormat','Not a valid seed or struct for RNG.'); end else - % Default to seed&state of current rng + % Default seed&state + rng('default'); self.rng_state = rng; end end