curl --request POST \
--url https://api.fincept.in/quantlib/physics/divergence/kl \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"p": [
0.35,
0.3,
0.2,
0.15
],
"q": [
0.25,
0.25,
0.25,
0.25
],
"base": 2.718281828459045
}
'{
"success": true,
"data": {
"kl_divergence": 0.1438
}
}{
"detail": "Invalid API key"
}{
"detail": "Insufficient credits. This endpoint requires 5 credits."
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}quantlib-physics
Calculate Kullback-Leibler Divergence
Calculates the Kullback-Leibler (KL) divergence from distribution Q to P, measuring how one probability distribution differs from a reference distribution. KL divergence is asymmetric and always non-negative. Essential for model comparison, portfolio rebalancing decisions, and detecting distribution shifts in market conditions.
Use Cases:
- Compare forecast distributions to realized outcomes
- Detect regime changes in market conditions
- Evaluate model performance and goodness-of-fit
- Measure portfolio drift from target allocation
- Assess information gain from new data
Formula: D_KL(P||Q) = Σ p(x) log(p(x)/q(x))
Credits: 5 credits per request (Pro Tier) [Tier: ENTERPRISE, Credits: 10]
POST
/
quantlib
/
physics
/
divergence
/
kl
curl --request POST \
--url https://api.fincept.in/quantlib/physics/divergence/kl \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"p": [
0.35,
0.3,
0.2,
0.15
],
"q": [
0.25,
0.25,
0.25,
0.25
],
"base": 2.718281828459045
}
'{
"success": true,
"data": {
"kl_divergence": 0.1438
}
}{
"detail": "Invalid API key"
}{
"detail": "Insufficient credits. This endpoint requires 5 credits."
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}Authorizations
API key for authentication. Get your key at https://api.fincept.in/auth/register
Body
application/json
⌘I
