logPDF function

@param val Value
@param dof Degrees of freedom
@return logPdf value
182311
public static double logpdf(double val, double dof) {
    if(val <= 0 || val == Double.POSITIVE_INFINITY) {
      return Double.NEGATIVE_INFINITY;
    }
    final double k = dof * .5;
    return (dof - 1.0) * FastMath.log(val) + (1 - k) * MathUtil.LOG2 - GammaDistribution.logGamma(k) - val * val / 2.;
  }
667967
public static double pdf(double val, double loc, double scale, double shape) {
    val = (val - loc) / scale;
    if(shape != 0.) {
      val = -FastMath.log(1 - shape * val) / shape;
    }
    double f = 1. + FastMath.exp(-val);
    return FastMath.exp(-val * (1 - shape)) / (scale * f * f);
  }
609231
def logpdf(self, X):
        
        return invwishart.logpdf(X, df=self.v, scale=self.Psi)
189515
def logpdf(self, x):
        
        if self.transform is not None:
            x = self.transform(x)       
        return (-self.alpha-1)*np.log(x) - (self.beta/float(x))
259353
public static Document buildPDFDocument (com.snowtide.pdf.Document pdf, LucenePDFConfiguration config) throws
            IOException {
        StringWriter sb = new StringWriter();
        pdf.pipe(new OutputTarget(sb));

        Document doc = new Document();

        LUCENE_INTERFACE.addField(doc, config.getBodyTextFieldName(), sb.toString(),
                config.storeBodyText(), config.indexBodyText(), config.tokenizeBodyText());

        for (Map.Entry<String, Object> metadataEntry : pdf.getAttributeMap().entrySet()) {
            String docPropName = metadataEntry.getKey();
            String fieldName = config.getMetadataFieldMapping(docPropName);
            if (fieldName == null) {
                if (config.copyAllPDFMetadata()) {
                    fieldName = docPropName;
                } else {
                    continue;
                }
            }

            Object value = metadataEntry.getValue();
            String valueStr;

            if (value == null) {
                if (LOG_DEBUG) log.debug("Null document property value found for name ["+docPropName+"] ("+pdf.getName()+')');
                continue;
            } else if (value instanceof String) {
                if (docPropName.equals(com.snowtide.pdf.Document.ATTR_MOD_DATE) ||
                        docPropName.equals(com.snowtide.pdf.Document.ATTR_CREATION_DATE)) {
                    try {
                        valueStr = DateTools.dateToString(PDFDateParser.parseDateString((String)value),
                                DateTools.Resolution.MILLISECOND);
                    } catch (Exception e) {
                        log.warn("PDF date string could not be parsed into a java.util.Date instance ["+value+"] ("+pdf.getName()+')', e);
                        valueStr = (String)value;
                    }
                } else {
                    valueStr = (String)value;
                }
            } else if (value instanceof Number) {
                valueStr = value.toString();
            } else {
                if (LOG_DEBUG) log.debug("Unexpected document property value type: "+value.getClass().getName()+
                        ", for name ("+docPropName+") ("+pdf.getName()+')');
                continue;
            }

            LUCENE_INTERFACE.addField(doc, fieldName, valueStr,
                    config.storeMetadata(), config.indexMetadata(), config.tokenizeMetadata());
        }

        return doc;
    }
978060
public void generatePdf(OutputStream out, List<Map<String, Object>> rows, List<ColumnDef> columns) {
        try {
            Document document = new Document();
            PdfWriter.getInstance(document, out);
            if (columns == null)
            {
                if (rows.size() > 0) return;
                columns = new ArrayList<ColumnDef>(CollectionUtils.collect(rows.get(0).keySet(), new Transformer() {
                    @Override
                    public Object transform(final Object input) {
                        return new ColumnDef()
                        {{
                                setName((String)input);
                            }};
                    }
                }));
            }
                if (columns.size() > 14)
                    document.setPageSize(PageSize.A1);
                else if (columns.size() > 10)
                    document.setPageSize(PageSize.A2);
                else if (columns.size() > 7)
                    document.setPageSize(PageSize.A3);
                else
                    document.setPageSize(PageSize.A4);
            document.open();
            Font font = FontFactory.getFont(FontFactory.COURIER, 8, Font.NORMAL, BaseColor.BLACK);
            Font headerFont = FontFactory.getFont(FontFactory.COURIER, 8, Font.BOLD, BaseColor.BLACK);

            int size = columns.size();
            PdfPTable table = new PdfPTable(size);
            for (ColumnDef column : columns)
            {
                PdfPCell c1 = new PdfPCell(new Phrase(column.getName(), headerFont));
                c1.setHorizontalAlignment(Element.ALIGN_CENTER);
                table.addCell(c1);
            }
            table.setHeaderRows(1);
            if (rows != null)
                for (Map<String, Object> row : rows)
                {
                    for (ColumnDef column : columns)
                    {
                        table.addCell(new Phrase(String.valueOf(row.get(column.getName())), font));
                    }
                }
            document.add(table);
            document.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
691549
public static double pdf(double val, double loc, double scale, double shape1, double shape2) {
    val = (val - loc) / scale;
    final double logc = logcdf(val, shape1, shape2);
    if(shape1 == 1.) {
      // Then val will usually become 0.
      return val >= 1 ? 0 : FastMath.exp(logc * (1. - shape2)) / scale;
    }
    if(shape1 != 0.) {
      val = shape1 * val;
      if(val >= 1) {
        return 0;
      }
      val = (1. - 1. / shape1) * FastMath.log1p(-val);
    }
    if(Double.isInfinite(val)) {
      return 0;
    }
    val = FastMath.exp(-val);
    return Double.isInfinite(val) ? 0. : val / scale * FastMath.exp(logc * (1. - shape2));
  }
12811
private static TextDecoration  parseTextDecoration(String val)
   {
      switch (val)
      {
         case NONE:           return Style.TextDecoration.None;
         case "underline":    return Style.TextDecoration.Underline;
         case "overline":     return Style.TextDecoration.Overline;
         case "line-through": return Style.TextDecoration.LineThrough;
         case "blink":        return Style.TextDecoration.Blink;
         default:             return null;
      }
   }
738437
def logpdf(self, mu):
        
        if self.transform is not None:
            mu = self.transform(mu)     
        return -np.log(float(self.sigma0)) - (0.5*(mu-self.mu0)**2)/float(self.sigma0**2)
1191185
public static double cdf(double val, double dof) {
    double v = val * val * .5;
    // regularizedGammaP will return NaN for infinite values!
    return val < 0. ? 0. : v < Double.POSITIVE_INFINITY ? GammaDistribution.regularizedGammaP(dof * .5, v) : v == v ? 1. : Double.NaN;
  }
22349
public static int getPdfPageCount(File inputPdfFile) {
        //get Ghostscript instance
        Ghostscript gs = Ghostscript.getInstance();

        //prepare Ghostscript interpreter parameters
        //refer to Ghostscript documentation for parameter usage
        //gs -q -dNODISPLAY -c "(input.pdf) (r) file runpdfbegin pdfpagecount = quit"
        List<String> gsArgs = new ArrayList<String>();
        gsArgs.add("-gs");
        gsArgs.add("-dNOPAUSE");
        gsArgs.add("-dQUIET");
        gsArgs.add("-dNODISPLAY");
        gsArgs.add("-dBATCH");
        gsArgs.add("-c");
        String cValue = String.format("(%s) (r) file runpdfbegin pdfpagecount = quit", inputPdfFile.getPath().replace('\\', '/'));
        gsArgs.add(cValue);

        int pageCount = 0;
        ByteArrayOutputStream os;

        //execute and exit interpreter
        try {
            synchronized (gs) {
                //output
                os = new ByteArrayOutputStream();
                gs.setStdOut(os);
                gs.initialize(gsArgs.toArray(new String[0]));
                pageCount = Integer.parseInt(os.toString().trim());
                os.close();
            }
        } catch (UnsatisfiedLinkError e) {
            logger.error(e.getMessage());
            throw new RuntimeException(getMessage(e.getMessage()));
        } catch (NoClassDefFoundError e) {
            logger.error(e.getMessage());
            throw new RuntimeException(getMessage(e.getMessage()));
        } catch (GhostscriptException e) {
            logger.error(e.getMessage());
            throw new RuntimeException(e.getMessage());
        } catch (Exception e) {
            logger.error(e.getMessage());
        } finally {
            //delete interpreter instance (safer)
            try {
                Ghostscript.deleteInstance();
            } catch (GhostscriptException e) {
                //nothing
            }
        }

        return pageCount;
    }
1283202
public static double logpdf(double val, double alpha, double beta) {
    return (alpha <= 0. || beta <= 0. || Double.isNaN(alpha) || Double.isNaN(beta) || Double.isNaN(val)) ? Double.NaN : //
        (val < 0. || val > 1.) ? Double.NEGATIVE_INFINITY : //
            val == 0. ? (alpha > 1. ? Double.NEGATIVE_INFINITY : alpha < 1. ? Double.POSITIVE_INFINITY : FastMath.log(beta)) //
                : val == 1. ? (beta > 1. ? Double.NEGATIVE_INFINITY : beta < 1. ? Double.POSITIVE_INFINITY : FastMath.log(alpha)) //
                    : -logBeta(alpha, beta) + FastMath.log(val) * (alpha - 1) + FastMath.log1p(-val) * (beta - 1);
  }
500984
@Override
	public Object doOutParameter(final String key, final Object val) {
		LOG.debug("Out parameter - Key:{}, value:{}", key, val);
		return val;
	}
425575
def d2logpdf_df2_dtheta(self, f, y, Y_metadata=None):
        
        if self.size > 0:
            if self.not_block_really:
                raise NotImplementedError("Need to make a decorator for this!")
            if isinstance(self.gp_link, link_functions.Identity):
                return self.d2logpdf_dlink2_dtheta(f, y, Y_metadata=Y_metadata)
            else:
                inv_link_f = self.gp_link.transf(f)
                dlink_df = self.gp_link.dtransf_df(f)
                d2link_df2 = self.gp_link.d2transf_df2(f)
                d2logpdf_dlink2_dtheta = self.d2logpdf_dlink2_dtheta(inv_link_f, y, Y_metadata=Y_metadata)
                dlogpdf_dlink_dtheta = self.dlogpdf_dlink_dtheta(inv_link_f, y, Y_metadata=Y_metadata)

                d2logpdf_df2_dtheta = np.zeros((self.size, f.shape[0], f.shape[1]))
                #Chain each parameter of hte likelihood seperately
                for p in range(self.size):
                    d2logpdf_df2_dtheta[p, :, :] = chain_2(d2logpdf_dlink2_dtheta[p,:,:], dlink_df, dlogpdf_dlink_dtheta[p,:,:], d2link_df2)
                return d2logpdf_df2_dtheta
                #return chain_2(d2logpdf_dlink2_dtheta, dlink_df, dlogpdf_dlink_dtheta, d2link_df2)
        else:
            # There are no parameters so return an empty array for derivatives
            return np.zeros((0, f.shape[0], f.shape[1]))
893971
public static double logpdf(double x, double mu, double sigma, double skew) {
    if(x != x) {
      return Double.NaN;
    }
    x = (x - mu) / sigma;
    if(skew == 0.) {
      return MathUtil.LOG_ONE_BY_SQRTTWOPI - FastMath.log(sigma) - .5 * x * x;
    }
    double y = -FastMath.log(1. - skew * x) / skew;
    if(y != y || y == Double.NEGATIVE_INFINITY || y == Double.NEGATIVE_INFINITY) {
      return Double.NEGATIVE_INFINITY;
    }
    return -.5 * y * y - FastMath.log(MathUtil.ONE_BY_SQRTTWOPI * sigma * (1 - skew * x));
  }
564788
public static double logpdf(double x, double mu, double sigma, double xi) {
    x = (x - mu) / sigma;
    // Check support:
    if(x < 0 || (xi < 0 && x > -1. / xi)) {
      return Double.NEGATIVE_INFINITY;
    }
    if(xi == 0) {
      return Double.POSITIVE_INFINITY;
    }
    return ((xi == -1) ? 0. : FastMath.log(1 + xi * x) * (-1 / xi - 1)) - FastMath.log(sigma);
  }
213993
public static double logpdf(double val, double loc, double scale, double shape) {
    val = (val - loc) / scale;
    double e = FastMath.exp(-val);
    return -(val + (shape + 1.0) * FastMath.log1p(e)) + FastMath.log(shape);
  }