Skip to content

Instantly share code, notes, and snippets.

#define OPENCL_PLATFORM_ID 0
#define OPENCL_DEVICE_ID 0
#define CL_USE_DEPRECATED_OPENCL_1_1_APIS
//#define USE_TIMING_OUTPUTS
//#include <CL/cl.hpp>
#include <Eigen/Dense>
#include <stan/math.hpp>
#include <vector>
#include <iostream>
This file has been truncated, but you can view the full file.
Phi(int)
Phi(real)
Phi(vector)
Phi(row vector)
Phi(matrix)
Phi(int[])
Phi(real[])
Phi(vector[])
Phi(row vector[])
Phi(matrix[])
@seantalts
seantalts / silly.cpp
Last active August 3, 2018 00:20
silly micro benchmarks for std::function vs custom functors
#include <vector>
#include <functional>
#include <Eigen/Dense>
#include <algorithm>
#include <iostream>
// CONFIGURABLE SIZES
typedef unsigned int index_t; // determines max expression size
typedef double real_t; // basic scalar type
cdf = function(x, pdf) {
sapply(x, function(x) {
integrate(pdf, -Inf, x)$value
})
}
u = cdf(rnorm(1e5), dnorm)
hist(u, breaks=100)
diff --git a/stan/math/prim/mat/fun/log_mix.hpp b/stan/math/prim/mat/fun/log_mix.hpp
index 3c7063ba3f..de82cc89b7 100644
--- a/stan/math/prim/mat/fun/log_mix.hpp
+++ b/stan/math/prim/mat/fun/log_mix.hpp
@@ -125,20 +125,20 @@ typename return_type<T_theta, T_lam>::type log_mix(const T_theta& theta,
* @param lambda array containing vectors of log densities.
* @return log mixture of densities in specified proportion
*/
-template <typename T_theta, typename T_lam>
-typename return_type<T_theta, std::vector<Eigen::Matrix<T_lam, -1, 1> > >::type
dans.rng = function(N_samp, n_eff, planck_length) {
pnorm(rnorm(N_samp, sd=1 + runif(N_samp, -1/sqrt(n_eff), 1/sqrt(n_eff))))
}
discrete.dan = function(N_samp, n_eff, pl) {
round(pnorm(rnorm(N_samp, sd=1 + runif(N_samp, -1/sqrt(n_eff), 1/sqrt(n_eff)))) * pl) / pl
}
linear_neff_plots = function(xlab, gen_data, n_samp, n_eff, planck_length) {
data = gen_data(n_samp, n_eff, planck_length)
bins <- n_eff * c(0.5, 1, 2, 3, 10, 50)
data {
int<lower=0> N; // num individuals
int<lower=1> K; // num ind predictors
int<lower=1> J; // num groups
int<lower=1> L; // num group predictors
int<lower=1,upper=J> jj[N]; // group for individual
}
generated quantities {
matrix[K, J] z;
data {
int<lower=0> N; // num individuals
int<lower=1> K; // num ind predictors
int<lower=1> J; // num groups
int<lower=1> L; // num group predictors
int<lower=1,upper=J> jj[N]; // group for individual
matrix[N, K] x; // individual predictors
matrix[J, L] u; // group predictors
vector[N] y; // outcomes
}
data {
int<lower=0> N; // num individuals
int<lower=1> K; // num ind predictors
int<lower=1> J; // num groups
int<lower=1> L; // num group predictors
int<lower=1,upper=J> jj[N]; // group for individual
matrix[N, K] x; // individual predictors
row_vector[L] u[J]; // group predictors
vector[N] y; // outcomes
}
@seantalts
seantalts / MicroKanren.hs
Last active July 27, 2016 19:12
MicroKanren (μKanren) in Haskell
module MicroKanren where
import Data.List (transpose)
import Data.Maybe
import Control.Monad
data Term = Var Int | Atom String
deriving (Eq, Show)
------------------------------------------