How to use the abcpy.probabilisticmodels.InputConnector.from_list function in abcpy

To help you get started, we’ve selected a few abcpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eth-cscs / abcpy / examples / backends / mpi / cpp / testModel.py View on Github external
def __init__(self, parameters, name='Normal'):
        # We expect input of type parameters = [mean, stddev]
        if not isinstance(parameters, list):
            raise TypeError('Input of normal model is of type list')

        if len(parameters) != 2:
            raise RuntimeError('Input list must be of length 2, containing [mean, stddev]')

        input_connector = InputConnector.from_list(parameters)
        super().__init__(input_connector, name)
github eth-cscs / abcpy / examples / backends / mpi / mpi_model_pmc.py View on Github external
def __init__(self, parameters, name='Gaussian'):
        # We expect input of type parameters = [mu, sigma]
        if not isinstance(parameters, list):
            raise TypeError('Input of Normal model is of type list')

        if len(parameters) != 2:
            raise RuntimeError('Input list must be of length 2, containing [mu1, mu1].')

        input_connector = InputConnector.from_list(parameters)
        super().__init__(input_connector, name)
github eth-cscs / abcpy / examples / backends / mpi / cpp / Inference.py View on Github external
def __init__(self, parameters, name='Normal'):
        # We expect input of type parameters = [mean, stddev]
        if not isinstance(parameters, list):
            raise TypeError('Input of normal model is of type list')

        if len(parameters) != 2:
            raise RuntimeError('Input list must be of length 2, containing [mean, stddev]')

        input_connector = InputConnector.from_list(parameters)
        super().__init__(input_connector, name)
github eth-cscs / abcpy / abcpy / continuousmodels.py View on Github external
----------
        parameters: list
            Contains the probabilistic models and hyperparameters from which the model derives.
            The list has two entries: from the first entry mean of the distribution and from the second entry variance is derived.
            Note that the second value of the list is strictly greater than 0.

        name: string
            The name that should be given to the probabilistic model in the journal file.
        """

        if not isinstance(parameters, list):
            raise TypeError('Input for Normal has to be of type list.')
        if len(parameters)<2:
            raise ValueError('Input for Normal has to be of length 2.')

        input_parameters = InputConnector.from_list(parameters)
        super(Normal, self).__init__(input_parameters, name)
        self.visited = False
github eth-cscs / abcpy / abcpy / probabilisticmodels.py View on Github external
----------
        parameters: list
            A list of ProbabilisticModels

        Returns
        -------
        InputConnector
        """

        if isinstance(parameters, list):
            unnested_parameters = []
            parameters_count = 0
            for item in parameters:
                input_parameters_from_item = item
                if isinstance(item, list):
                    input_parameters_from_item = InputConnector.from_list(item)
                elif isinstance(item, (Hyperparameter, ProbabilisticModel)):
                    input_parameters_from_item = InputConnector.from_model(item)
                elif isinstance(item, Number):
                    input_parameters_from_item = InputConnector.from_number(item)
                elif not isinstance(item, InputConnector):
                    raise TypeError('Unsupported type.')

                unnested_parameters.append(input_parameters_from_item)
                parameters_count += input_parameters_from_item.get_parameter_count()

            # here, unnested_parameters is a list of InputConnector and parameters_count hold the total number of
            # parameters in this list
            input_parameters = InputConnector(parameters_count)
            index = 0
            for param in unnested_parameters:
                for pi in range(0, param.get_parameter_count()):
github eth-cscs / abcpy / abcpy / discretemodels.py View on Github external
Parameters
        ----------
        parameters: list
             A list containing one entry, the probability of the distribution.

        name: string
            The name that should be given to the probabilistic model in the journal file.
        """

        if not isinstance(parameters, list):
            raise TypeError('Input for Bernoulli has to be of type list.')
        if len(parameters)!=1:
            raise ValueError('Input for Bernoulli has to be of length 1.')

        self._dimension = len(parameters)
        input_parameters = InputConnector.from_list(parameters)
        super(Bernoulli, self).__init__(input_parameters, name)
        self.visited = False
github eth-cscs / abcpy / abcpy / discretemodels.py View on Github external
Parameters
        ----------
        parameters: list
            A list containing one entry, the mean of the distribution.

        name: string
            The name that should be given to the probabilistic model in the journal file.
        """

        if not isinstance(parameters, list):
            raise TypeError('Input for Poisson has to be of type list.')
        if len(parameters)!=1:
            raise ValueError('Input for Poisson has to be of length 1.')

        self._dimension = 1
        input_parameters = InputConnector.from_list(parameters)
        super(Poisson, self).__init__(input_parameters, name)
        self.visited = False
github eth-cscs / abcpy / examples / backends / mpi / mpi_model_inferences.py View on Github external
def __init__(self, parameters, name='Gaussian'):
        # We expect input of type parameters = [mu, sigma]
        if not isinstance(parameters, list):
            raise TypeError('Input of Normal model is of type list')

        if len(parameters) != 2:
            raise RuntimeError('Input list must be of length 2, containing [mu1, mu1].')

        input_connector = InputConnector.from_list(parameters)
        super().__init__(input_connector, name)