Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding support for 1d distributions. #158

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion numcosmo/math/ncm_stats_dist.c
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ _ncm_stats_dist_prepare (NcmStatsDist *sd)
break;
}

if (self->n_obs < self->d)
if (self->n_obs <= self->d)
g_error ("_ncm_stats_dist_prepare: the sample is too small.");

sd_class->prepare_kernel (sd, self->sample_array);
Expand Down
2 changes: 1 addition & 1 deletion numcosmo/math/ncm_stats_dist_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ ncm_stats_dist_kernel_class_init (NcmStatsDistKernelClass *klass)
g_param_spec_uint ("dimension",
NULL,
"Kernel dimension",
2, G_MAXUINT, 2,
1, G_MAXUINT, 2,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_NAME | G_PARAM_STATIC_BLURB));

sd_class->set_dim = &_ncm_stats_dist_kernel_set_dim;
Expand Down
2 changes: 1 addition & 1 deletion numcosmo/math/ncm_stats_vec.c
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ _ncm_stats_vec_constructed (GObject *object)
switch (svec->t)
{
case NCM_STATS_VEC_COV:
g_assert_cmpuint (svec->len, >, 1);
g_assert_cmpuint (svec->len, >, 0);
g_assert (svec->cov == NULL);

svec->cov = ncm_matrix_new (svec->len, svec->len);
Expand Down
4 changes: 2 additions & 2 deletions tests/test_ncm_fit_esmcmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ main (gint argc, gchar *argv[])
void
test_ncm_fit_esmcmc_new_apes (TestNcmFitESMCMC *test, gconstpointer pdata)
{
const gint dim = test->dim = g_test_rand_int_range (2, 4);
const gint dim = test->dim = g_test_rand_int_range (1, 4);
const gint nwalkers = 100 * test->dim;
NcmRNG *rng = ncm_rng_seeded_new (NULL, g_test_rand_int ());
NcmDataGaussCovMVND *data_mvnd = ncm_data_gauss_cov_mvnd_new_full (dim, 2.0e-2, 5.0e-2, 30.0, 1.0, 2.0, rng);
Expand Down Expand Up @@ -273,7 +273,7 @@ test_ncm_fit_esmcmc_new_apes (TestNcmFitESMCMC *test, gconstpointer pdata)
void
test_ncm_fit_esmcmc_new_stretch (TestNcmFitESMCMC *test, gconstpointer pdata)
{
const gint dim = test->dim = g_test_rand_int_range (2, 4);
const gint dim = test->dim = g_test_rand_int_range (1, 4);
const gint nwalkers = 10 * g_test_rand_int_range (2, 5);
NcmRNG *rng = ncm_rng_seeded_new (NULL, g_test_rand_int ());
NcmDataGaussCovMVND *data_mvnd = ncm_data_gauss_cov_mvnd_new_full (dim, 1.0e-2, 2.0e-2, 30.0, 1.0, 2.0, rng);
Expand Down
8 changes: 4 additions & 4 deletions tests/test_ncm_stats_dist.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ main (gint argc, gchar *argv[])
static void
test_ncm_stats_dist_new_kde_gauss (TestNcmStatsDist *test, gconstpointer pdata)
{
const guint dim = g_test_rand_int_range (2, 4);
const guint dim = g_test_rand_int_range (1, 4);
NcmStatsDistKernelGauss *sdk_gauss = ncm_stats_dist_kernel_gauss_new (dim);
NcmStatsDistKDE *sdkde = ncm_stats_dist_kde_new (NCM_STATS_DIST_KERNEL (sdk_gauss), NCM_STATS_DIST_CV_NONE);
NcmStatsDistKDECovType cov_type = GPOINTER_TO_INT (pdata);
Expand Down Expand Up @@ -210,7 +210,7 @@ static void
test_ncm_stats_dist_new_kde_studentt (TestNcmStatsDist *test, gconstpointer pdata)
{
const gdouble nu = g_test_rand_double_range (3.0, 5.0);
const guint dim = g_test_rand_int_range (2, 4);
const guint dim = g_test_rand_int_range (1, 4);
NcmStatsDistKernelST *sdk_st = ncm_stats_dist_kernel_st_new (dim, nu);
NcmStatsDistKDE *sdkde = ncm_stats_dist_kde_new (NCM_STATS_DIST_KERNEL (sdk_st), NCM_STATS_DIST_CV_NONE);
NcmStatsDistKDECovType cov_type = GPOINTER_TO_INT (pdata);
Expand Down Expand Up @@ -260,7 +260,7 @@ test_ncm_stats_dist_new_kde_studentt (TestNcmStatsDist *test, gconstpointer pdat
static void
test_ncm_stats_dist_new_vkde_gauss (TestNcmStatsDist *test, gconstpointer pdata)
{
const guint dim = g_test_rand_int_range (2, 4);
const guint dim = g_test_rand_int_range (1, 4);
NcmStatsDistKernelGauss *sdk_gauss = ncm_stats_dist_kernel_gauss_new (dim);
NcmStatsDistVKDE *sdvkde = ncm_stats_dist_vkde_new (NCM_STATS_DIST_KERNEL (sdk_gauss), NCM_STATS_DIST_CV_NONE);
NcmStatsDistKDECovType cov_type = GPOINTER_TO_INT (pdata);
Expand Down Expand Up @@ -312,7 +312,7 @@ static void
test_ncm_stats_dist_new_vkde_studentt (TestNcmStatsDist *test, gconstpointer pdata)
{
const gdouble nu = g_test_rand_double_range (3.0, 5.0);
const guint dim = g_test_rand_int_range (2, 4);
const guint dim = g_test_rand_int_range (1, 4);
NcmStatsDistKernelST *sdk_st = ncm_stats_dist_kernel_st_new (dim, nu);
NcmStatsDistVKDE *sdvkde = ncm_stats_dist_vkde_new (NCM_STATS_DIST_KERNEL (sdk_st), NCM_STATS_DIST_CV_NONE);
NcmStatsDistKDECovType cov_type = GPOINTER_TO_INT (pdata);
Expand Down
16 changes: 8 additions & 8 deletions tests/test_ncm_stats_dist_kernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ typedef struct _TestNcmStatsDistKernelFunc

static TestNcmStatsDistKernelFunc constructors[TEST_NCM_STATS_DIST_KERNEL_CONSTRUCTORS_LEN] = {
{"gauss", &test_ncm_stats_dist_kernel_new_gauss},
{"st", &test_ncm_stats_dist_kernel_new_st}
{"st", &test_ncm_stats_dist_kernel_new_st}
};

static TestNcmStatsDistKernelFunc tests[TEST_NCM_STATS_DIST_KERNEL_TESTS_LEN] = {
{"dim", &test_ncm_stats_dist_kernel_dim},
{"band", &test_ncm_stats_dist_kernel_bandwidth},
{"gauss/norm", &test_ncm_stats_dist_kernel_norm},
{"sum", &test_ncm_stats_dist_kernel_sum},
{"sample", &test_ncm_stats_dist_kernel_sample},
{"dim", &test_ncm_stats_dist_kernel_dim},
{"band", &test_ncm_stats_dist_kernel_bandwidth},
{"gauss/norm", &test_ncm_stats_dist_kernel_norm},
{"sum", &test_ncm_stats_dist_kernel_sum},
{"sample", &test_ncm_stats_dist_kernel_sample},
};

gint
Expand Down Expand Up @@ -129,7 +129,7 @@ main (gint argc, gchar *argv[])
static void
test_ncm_stats_dist_kernel_new_gauss (TestNcmStatsDistKernel *test, gconstpointer pdata)
{
const guint dim = g_test_rand_int_range (2, 4);
const guint dim = g_test_rand_int_range (1, 4);
NcmStatsDistKernelGauss *sdk_gauss = ncm_stats_dist_kernel_gauss_new (dim);

test->dim = dim;
Expand All @@ -151,7 +151,7 @@ static void
test_ncm_stats_dist_kernel_new_st (TestNcmStatsDistKernel *test, gconstpointer pdata)
{
const gdouble nu = g_test_rand_double_range (3.0, 5.0);
const guint dim = g_test_rand_int_range (2, 4);
const guint dim = g_test_rand_int_range (1, 4);
NcmStatsDistKernelST *sdk_st = ncm_stats_dist_kernel_st_new (dim, nu);

test->dim = dim;
Expand Down