Skip to content

Allow support of unequal numbers of points per dimension #123

@htoftevaag

Description

@htoftevaag

Support for unequal numbers of points per dimension

Desired Behavior / Functionality

Torchquad currently only supports equal numbers of points per dimension for the deterministic methods (that use integration_grid.py). The user might want to use more points in one dimension than the others (if, for instance, the integration domain in one dimension is much larger than in the others or the function is more complex in certain dimensions).
Exactly how this should be implemented can be a bit up the contributor - perhaps the ideal solution is allowing many different types of input (see below).

What Needs to Be Done

Under torchquad.integration_grid.py, we have the following comment # TODO Add that N can be different for each dimension.
Currently, what happens is that the number of sample points per dimension (self._N) is set to the _n_th root of the total number of sample points, N, where n is the number of dimensions.
self._N = int(N ** (1.0 / self._dim) + 1e-8) # convert to points per dim (the 1e-8 term here is explained in the code).

It would be nice to allow self_N to be for instance [16, 2, 2] instead of [4, 4, 4].

One solution could be to do the following:

If N is an integer, then let self._N be the _n_th root of N.
If N is a list/array, then let self._N be the list/array.

Note: For Monte Carlo and VEGAS, varying the number of points per dimension doesn't make sense.

How Can It Be Tested

A good place to start is to check if the tests fail, in particular the integration_grid_test.py.
Ideally, additional tests should be added to integration_grid_test.py.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions