jeremylichtman / cdf_generator
A port to PHP from Python of the Metaculus CDF 201-value generator code.
1.0.0
2026-11-30 17:05 UTC
Requires
- php: ^8.3.7
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
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:
- From your terminal:
composer require 'jeremylichtman/cdf_generator'
- 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);