Skip to content

Commit 9d1c79b

Browse files
vectorized densities evaluate OK -- need to check results
1 parent 07d7c6c commit 9d1c79b

File tree

3 files changed

+27
-6
lines changed

3 files changed

+27
-6
lines changed

selectiveInference/R/funs.randomized.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ randomizedLASSO = function(X,
124124
inactive_set = inactive_set,
125125
unpenalized_set = unpenalized_set,
126126
sign_soln = sign_soln,
127-
opt_transform = opt_transform,
127+
optimization_transform = opt_transform,
128128
internal_transform = internal_transform
129129
))
130130

selectiveInference/src/Rcpp-randomized.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Rcpp::NumericVector log_density_gaussian_(double noise_scale,
77
Rcpp::NumericMatrix internal_state, // D -- data state -- matrix of shape (nopt, npts)
88
Rcpp::NumericMatrix optimization_linear, // A_O -- linear part for optimization variables
99
Rcpp::NumericMatrix optimization_state, // O -- optimization state -- matrix of shape (ninternal, npts)
10-
Rcpp::NumericMatrix offset) { // h -- offset in affine transform -- "p" dimensional
10+
Rcpp::NumericVector offset) { // h -- offset in affine transform -- "p" dimensional
1111

1212
int npt = internal_state.ncol(); // Function is vectorized
1313
if (optimization_state.ncol() != npt) { // Assuming each column is an internal or opt state because arrays are column major
@@ -43,7 +43,7 @@ Rcpp::NumericVector log_density_gaussian_(double noise_scale,
4343
Rcpp::NumericVector log_density_gaussian_conditional_(double noise_scale, // Scale of randomization
4444
Rcpp::NumericMatrix optimization_linear, // A_O -- linear part for optimization variables
4545
Rcpp::NumericMatrix optimization_state, // O -- optimization state -- matrix of shape (ninternal, npts)
46-
Rcpp::NumericMatrix offset) { // h -- offset in affine transform -- "p" dimensional
46+
Rcpp::NumericVector offset) { // h -- offset in affine transform -- "p" dimensional
4747

4848
int npt = optimization_state.ncol(); // Function is vectorized
4949
int ndim = optimization_linear.nrow();

tests/randomized/test_randomized.R

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
library(selectiveInference)
22

3-
test = function() {
3+
smoke_test = function() {
44

55
n = 100; p = 50
66
X = matrix(rnorm(n * p), n, p)
@@ -10,6 +10,27 @@ test = function() {
1010
ridge_term = .1 / sqrt(n)
1111
selectiveInference:::randomizedLASSO(X, y, lam, noise_scale, ridge_term)
1212
}
13+
A = smoke_test()
1314

14-
A=test()
15-
#print(test())
15+
density_test = function() {
16+
17+
random_lasso = smoke_test()
18+
p = nrow(random_lasso$internal_transform$linear_term)
19+
internal_state = matrix(rnorm(p * 20), p, 20)
20+
optimization_state = matrix(rnorm(p * 20), p, 20)
21+
offset = rnorm(p)
22+
23+
selectiveInference:::log_density_gaussian_(10.,
24+
random_lasso$internal_transform$linear_term,
25+
internal_state,
26+
random_lasso$optimization_transform$linear_term,
27+
optimization_state,
28+
offset)
29+
30+
selectiveInference:::log_density_gaussian_conditional_(10.,
31+
random_lasso$optimization_transform$linear_term,
32+
optimization_state,
33+
offset)
34+
}
35+
36+
density_test()

0 commit comments

Comments
 (0)