> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fincept.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate Mutual Information

> Calculates the mutual information I(X;Y) between two random variables, measuring the reduction in uncertainty of one variable due to knowledge of the other. Mutual information is symmetric, always non-negative, and captures both linear and non-linear dependencies, making it superior to correlation for detecting complex relationships.

**Use Cases:**
- Detect non-linear dependencies between assets
- Feature selection for predictive models
- Measure information flow between markets
- Quantify predictive relationships
- Portfolio diversification analysis

**Formula:** I(X;Y) = H(X) + H(Y) - H(X,Y) = H(X) - H(X|Y)

**Credits:** 5 credits per request (Pro Tier) [Tier: ENTERPRISE, Credits: 10]



## OpenAPI

````yaml api-specs/physics.json post /quantlib/physics/entropy/mutual-information
openapi: 3.1.0
info:
  title: FinceptQuantLib API - Physics Module
  description: >-
    Physics and Information Theory module for FinceptQuantLib API. Includes
    Shannon/Renyi/Tsallis entropy, KL/JS divergence, mutual information,
    transfer entropy, Fisher information, Boltzmann distribution, Ising model,
    maximum entropy, thermodynamics (free energy, Carnot cycle, van der Waals
    equation), and Maxwell relations. **Pro Tier required. 5 credits per
    request.**
  version: 3.0.0
  contact:
    name: Fincept API Support
    url: https://fincept.in
servers:
  - url: https://api.fincept.in
    description: Fincept API Production Server
security:
  - APIKeyHeader: []
tags:
  - name: quantlib-physics
    description: Physics and Information Theory module for FinceptQuantLib API
    x-displayName: Physics
paths:
  /quantlib/physics/entropy/mutual-information:
    post:
      tags:
        - quantlib-physics
      summary: Calculate Mutual Information
      description: >-
        Calculates the mutual information I(X;Y) between two random variables,
        measuring the reduction in uncertainty of one variable due to knowledge
        of the other. Mutual information is symmetric, always non-negative, and
        captures both linear and non-linear dependencies, making it superior to
        correlation for detecting complex relationships.


        **Use Cases:**

        - Detect non-linear dependencies between assets

        - Feature selection for predictive models

        - Measure information flow between markets

        - Quantify predictive relationships

        - Portfolio diversification analysis


        **Formula:** I(X;Y) = H(X) + H(Y) - H(X,Y) = H(X) - H(X|Y)


        **Credits:** 5 credits per request (Pro Tier) [Tier: ENTERPRISE,
        Credits: 10]
      operationId: mutual_information
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - joint_prob
              properties:
                joint_prob:
                  type: array
                  items:
                    type: array
                    items:
                      type: number
                  description: Joint probability matrix (must sum to 1)
                  example:
                    - - 0.4
                      - 0.1
                      - 0.05
                    - - 0.05
                      - 0.3
                      - 0.05
                    - - 0.02
                      - 0.01
                      - 0.02
                base:
                  type: number
                  description: Logarithm base for information calculation
                  default: 2.718281828459045
                  example: 2.718281828459045
            examples:
              strong_dependency:
                summary: Strong dependency (high MI)
                value:
                  joint_prob:
                    - - 0.45
                      - 0.05
                      - 0
                    - - 0.05
                      - 0.4
                      - 0.05
                    - - 0
                      - 0
                      - 0
                  base: 2.718281828459045
              independence:
                summary: Independent variables (MI≈0)
                value:
                  joint_prob:
                    - - 0.15
                      - 0.15
                      - 0.1
                    - - 0.15
                      - 0.15
                      - 0.1
                    - - 0.1
                      - 0.1
                      - 0
                  base: 2
      responses:
        '200':
          description: Mutual information calculated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      mutual_information:
                        type: number
                        description: >-
                          Mutual information value (0 = independent, higher =
                          stronger dependency)
                        example: 0.5623
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/InsufficientCreditsError'
        '422':
          $ref: '#/components/responses/ValidationError'
components:
  responses:
    UnauthorizedError:
      description: Authentication information is missing or invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Invalid API key
    InsufficientCreditsError:
      description: Insufficient API credits
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Insufficient credits. This endpoint requires 5 credits.
    ValidationError:
      description: Request validation error
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: array
                items:
                  type: object
                  properties:
                    loc:
                      type: array
                      items:
                        type: string
                    msg:
                      type: string
                    type:
                      type: string
  securitySchemes:
    APIKeyHeader:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        API key for authentication. Get your key at
        https://api.fincept.in/auth/register

````