1c758ba9d6c14d9b9d3599e44c3508e2692d8d35,pyprob/distributions/empirical.py,Empirical,mode,#Empirical#,155

Before Change



    @property
    def mode(self):
        if self.length == 0:
            raise RuntimeError("Empirical distribution instance is empty.")
        if self._uniform_weights:
            print(colored("Warning: weights are uniform and there is no unique mode.", "red", attrs=["bold"]))
        if self._mode is None:
            if self.sorted_by_weights:
                self._mode = self.values[0]
            else:
                _, max_index = self.weights.max(-1)
                self._mode = self.values[int(max_index)]
        return self._mode

    @property

After Change


        return self._variance

    @property
    def mode(self):
        self._check_finalized()
        // if self._uniform_weights:
        //     print(colored("Warning: weights are uniform and there is no unique mode.", "red", attrs=["bold"]))
        if self._mode is None:
            _, max_index = util.to_tensor(self._log_weights).max(-1)
            self._mode = self._get_value(int(max_index))
        return self._mode
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 9

Instances


Project Name: pyprob/pyprob
Commit Name: 1c758ba9d6c14d9b9d3599e44c3508e2692d8d35
Time: 2018-09-28
Author: atilimgunes.baydin@gmail.com
File Name: pyprob/distributions/empirical.py
Class Name: Empirical
Method Name: mode


Project Name: pyprob/pyprob
Commit Name: 1c758ba9d6c14d9b9d3599e44c3508e2692d8d35
Time: 2018-09-28
Author: atilimgunes.baydin@gmail.com
File Name: pyprob/distributions/empirical.py
Class Name: Empirical
Method Name: mode


Project Name: pyprob/pyprob
Commit Name: 1c758ba9d6c14d9b9d3599e44c3508e2692d8d35
Time: 2018-09-28
Author: atilimgunes.baydin@gmail.com
File Name: pyprob/distributions/empirical.py
Class Name: Empirical
Method Name: sample


Project Name: pyprob/pyprob
Commit Name: 1c758ba9d6c14d9b9d3599e44c3508e2692d8d35
Time: 2018-09-28
Author: atilimgunes.baydin@gmail.com
File Name: pyprob/distributions/empirical.py
Class Name: Empirical
Method Name: expectation