Search by

jeremylichtman / cdf_generator

jeremylichtman

A port to PHP from Python of the Metaculus CDF 201-value generator code.

Package info

github.com/jeremylichtman/cdf_generator

pkg:composer/jeremylichtman/cdf_generator

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-11-30 17:05 UTC

This package is not auto-updated.

Last update: 2026-12-01 15:25:51 UTC


README

A port to PHP of the Metaculus CDF 201-value generator code.

Original code can be found inside of the Metaculus bot source code: https://github.com/Metaculus/metac-bot-template. This is written in Python, and therefore is not usable by PHP developers. The port used LLM-generated code, which has been manually edited and tested.

NOTE: PHP array keys cannot be floats (they get truncated to int). In generate_continuous_cdf(), pass fractional percentiles as string keys, e.g. ["2.5" => 10.0, 50 => 20.0, "97.5" => 30.0].

Usage:

  1. From your terminal:
composer require 'jeremylichtman/cdf_generator'
  1. Code sample. Production code should catch the InvalidArgumentException and LogicException error classes.
use jeremylichtman\CdfGenerator;

$percentile_values = [
  '5' => 1,
  '25' => 10,
  '50' => 20,
  '75' => 44,
  '95' => 25,
];

$cdf_values = CdfGenerator::generate_continuous_cdf(
  $percentile_values,
  $open_upper_bound = FALSE,
  $open_lower_bound = FALSE,
  $upper_bound = 99,
  $lower_bound = 1,
  $zero_point = 0,
  $cdf_size = 201,
);

print_r($cdf_values);