curl --request POST \
--url https://api.fincept.in/quantlib/physics/divergence/js \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"p": [
0.4,
0.3,
0.2,
0.1
],
"q": [
0.35,
0.35,
0.2,
0.1
],
"base": 2.718281828459045
}
'{
"success": true,
"data": {
"js_divergence": 0.0234
}
}{
"detail": "Invalid API key"
}{
"detail": "Insufficient credits. This endpoint requires 5 credits."
}{
"detail": [
{
"loc": [
"<string>"
],
"msg": "<string>",
"type": "<string>"
}
]
}quantlib-physics
Calculate Jensen-Shannon Divergence
Calculates the Jensen-Shannon (JS) divergence between two probability distributions. JS divergence is symmetric, bounded (0 to 1), and based on the KL divergence. It’s particularly useful when you need a symmetric distance measure between distributions and is more numerically stable than KL divergence.
Use Cases:
- Compare similarity between return distributions
- Symmetric portfolio comparison metrics
- Clustering market regimes
- Model selection with symmetric criteria
- Distribution matching in risk modeling
Formula: JS(P||Q) = 0.5 * D_KL(P||M) + 0.5 * D_KL(Q||M), where M = 0.5(P+Q)
Credits: 5 credits per request (Pro Tier) [Tier: ENTERPRISE, Credits: 10]
POST
/
quantlib
/
physics
/
divergence
/
js
curl --request POST \
--url https://api.fincept.in/quantlib/physics/divergence/js \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <api-key>' \
--data '
{
"p": [
0.4,
0.3,
0.2,
0.1
],
"q": [
0.35,
0.35,
0.2,
0.1
],
"base": 2.718281828459045
}
'{
"success": true,
"data": {
"js_divergence": 0.0234
}
}{
"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
