コード例 #1
0
    def ppf(self, x):
        # convert the parameter to the right format
        if isList(x):
            x = DataVector(x)
        elif isNumerical(x):
            x = DataVector([x])
        elif isMatrix(x):
            x = DataMatrix(x)

        if isinstance(x, DataMatrix):
            A = x
            B = DataMatrix(A.getNrows(), A.getNcols())
            B.setAll(0.0)
        elif isinstance(x, DataVector):
            A = DataMatrix(1, len(x))
            A.setRow(0, x)
            B = DataMatrix(1, len(x))
            B.setAll(0)

        # do the transformation
        opInvRosen = createOperationInverseRosenblattTransformationKDE(self.dist)
        opInvRosen.doTransformation(A, B)

        # transform the outcome
        if isNumerical(x) or isinstance(x, DataVector):
            return B.get(0, 0)
        elif isinstance(x, DataMatrix):
            return B.array()
コード例 #2
0
    def ppf(self, x):
        # convert the parameter to the right format
        if isList(x):
            x = DataVector(x)
        elif isNumerical(x):
            x = DataVector([x])

        if isinstance(x, DataMatrix):
            A = x
            B = DataMatrix(A.getNrows(), A.getNcols())
            B.setAll(0.0)
        elif isinstance(x, DataVector):
            A = DataMatrix(1, len(x))
            A.setRow(0, x)
            B = DataMatrix(1, len(x))
            B.setAll(0)

        # do the transformation
        assert A.getNcols() == B.getNcols() == self.trainData.getNcols()
        op = createOperationInverseRosenblattTransformationKDE(self.trainData)
        op.doTransformation(A, B)

        # transform the outcome
        if isNumerical(x) or isinstance(x, DataVector):
            return B.get(0, 0)
        elif isinstance(x, DataMatrix):
            return B.array()
コード例 #3
0
ファイル: NatafDist.py プロジェクト: ABAtanasov/Sparse-Grids
    def cdf(self, x):
        # convert the parameter to the right format
        if isList(x):
            x = DataVector(x)
        elif isNumerical(x):
            x = DataVector([x])
        elif isMatrix(x):
            x = DataMatrix(x)

        if isinstance(x, DataMatrix):
            A = x
            B = DataMatrix(A.getNrows(), A.getNcols())
            B.setAll(0.0)
        elif isinstance(x, DataVector):
            A = DataMatrix(1, len(x))
            A.setRow(0, x)
            B = DataMatrix(1, len(x))
            B.setAll(0)

        # do the transformation
        self.dist.cdf(A, B)

        # transform the outcome
        if isNumerical(x) or isinstance(x, DataVector):
            return B.get(0, 0)
        elif isinstance(x, DataMatrix):
            return B.array()
コード例 #4
0
    def ppf(self, x):
        # convert the parameter to the right format
        if isList(x):
            x = DataVector(x)
        elif isNumerical(x):
            x = DataVector([x])
        elif isMatrix(x):
            x = DataMatrix(x)

        if isinstance(x, DataMatrix):
            A = x
            B = DataMatrix(A.getNrows(), A.getNcols())
            B.setAll(0.0)
        elif isinstance(x, DataVector):
            A = DataMatrix(1, len(x))
            A.setRow(0, x)
            B = DataMatrix(1, len(x))
            B.setAll(0)

        # do the transformation
        self.dist.ppf(A, B)

        # transform the outcome
        if isNumerical(x) or isinstance(x, DataVector):
            return B.get(0, 0)
        elif isinstance(x, DataMatrix):
            return B.array()
コード例 #5
0
ファイル: DTreesDist.py プロジェクト: ABAtanasov/Sparse-Grids
 def pdf(self, x):
     if isNumerical(x):
         x = [x]
     x = tuple(x)
     if x in self.testData:
         return self.testData[x]
     else:
         raise AttributeError("No pdf value for '%s' available" % (x,))
コード例 #6
0
ファイル: DTreesDist.py プロジェクト: jsgphd/Sparse-Grids
 def pdf(self, x):
     if isNumerical(x):
         x = [x]
     x = tuple(x)
     if x in self.testData:
         return self.testData[x]
     else:
         raise AttributeError("No pdf value for '%s' available" % (x, ))
コード例 #7
0
ファイル: EstimatedDist.py プロジェクト: pfluegdk/SGpp
 def _convertEvalPoint(self, x):
     # convert the parameter to the right format
     if self.dim == 1:
         if isNumerical(x):
             x = np.array([[x]])
         elif isList(x) or len(x.shape) == 1:
             x = np.array([x]).reshape(len(x), 1)
     else:
         x = np.array(x)
         if len(x.shape) == 1:
             x = np.array([x])
     return x
コード例 #8
0
    def pdf(self, x):
        # convert the parameter to the right format
        if isList(x):
            x = DataVector(x)
        elif isNumerical(x):
            x = DataVector([x])

        if isinstance(x, DataMatrix):
            A = x
            res = DataVector(A.getNrows())
            res.setAll(0.0)
        elif isinstance(x, DataVector):
            A = DataMatrix(1, len(x))
            A.setRow(0, x)
            res = DataVector(1)
            res.setAll(0)

        self.dist.pdf(A, res)

        if len(res) == 1:
            return res[0]
        else:
            return res.array()
コード例 #9
0
    def pdf(self, x):
        # convert the parameter to the right format
        if isList(x):
            x = DataVector(x)
        elif isNumerical(x):
            x = DataVector([x])

        if isinstance(x, DataMatrix):
            A = x
            res = DataVector(A.getNrows())
            res.setAll(0.0)
        elif isinstance(x, DataVector):
            A = DataMatrix(1, len(x))
            A.setRow(0, x)
            res = DataVector(1)
            res.setAll(0)

        self.dist.pdf(A, res)

        if len(res) == 1:
            return res[0]
        else:
            return res.array()