> ## 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.

# Monte Carlo Integration

> Estimate the integral of a function over a hyper-rectangle using Monte Carlo sampling. Particularly effective for high-dimensional integrals where traditional methods suffer from the curse of dimensionality. Returns both the integral estimate and standard error, allowing confidence interval construction. Essential for option pricing, risk calculations, and multidimensional probability computations. [Tier: BASIC, Credits: 1]



## OpenAPI

````yaml api-specs/numerical.json post /quantlib/numerical/integration/monte-carlo
openapi: 3.1.0
info:
  title: FinceptQuantLib API - Numerical
  description: >-
    Numerical module endpoints for FinceptQuantLib API. The Numerical module
    (Basic Tier, 1 credit per request) provides comprehensive numerical methods
    including finite difference differentiation, Fast Fourier Transform (FFT),
    numerical integration (quadrature and Monte Carlo), interpolation methods
    (linear, cubic, spline), linear algebra operations (matrix decomposition,
    solving systems), ODE solvers, root finding algorithms, optimization
    methods, and nonlinear least squares fitting. Essential for quantitative
    analysis, scientific computing, and numerical model implementation.
  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-numerical
    description: >-
      Numerical methods including differentiation, FFT, integration,
      interpolation, linear algebra, ODE solvers, root finding, and optimization
    x-displayName: Numerical
paths:
  /quantlib/numerical/integration/monte-carlo:
    post:
      tags:
        - quantlib-numerical
      summary: Monte Carlo Integration
      description: >-
        Estimate the integral of a function over a hyper-rectangle using Monte
        Carlo sampling. Particularly effective for high-dimensional integrals
        where traditional methods suffer from the curse of dimensionality.
        Returns both the integral estimate and standard error, allowing
        confidence interval construction. Essential for option pricing, risk
        calculations, and multidimensional probability computations. [Tier:
        BASIC, Credits: 1]
      operationId: monte_carlo_integration
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - func_name
                - bounds
              properties:
                func_name:
                  type: string
                  description: >-
                    Built-in function (multi-variable for multi-d, scalar for
                    1-d)
                  enum:
                    - rosenbrock
                    - sphere
                    - rastrigin
                    - quadratic
                    - exp
                    - sin
                    - cos
                  example: sphere
                bounds:
                  type: array
                  items:
                    type: array
                    items:
                      type: number
                    minItems: 2
                    maxItems: 2
                  description: >-
                    Integration bounds for each dimension [[a1,b1], [a2,b2],
                    ...]
                  example:
                    - - -1
                      - 1
                    - - -1
                      - 1
                n_samples:
                  type: integer
                  description: Number of Monte Carlo samples (more samples = more accurate)
                  default: 10000
                  example: 10000
                seed:
                  type: integer
                  description: Random seed for reproducibility
                  default: 42
                  example: 42
            example:
              func_name: sphere
              bounds:
                - - -1
                  - 1
                - - -1
                  - 1
              n_samples: 10000
              seed: 42
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      estimate:
                        type: number
                        description: Monte Carlo estimate of the integral
                        example: 2.6667
                      std_error:
                        type: number
                        description: Standard error of the estimate
                        example: 0.0235
                      n_samples:
                        type: integer
                        description: Number of samples used
                        example: 10000
              example:
                success: true
                data:
                  estimate: 2.6667
                  std_error: 0.0235
                  n_samples: 10000
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/InsufficientTierError'
        '422':
          description: Validation Error
      security:
        - APIKeyHeader: []
components:
  responses:
    UnauthorizedError:
      description: Authentication information is missing or invalid
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Invalid API key
    InsufficientTierError:
      description: API tier insufficient for this endpoint
      content:
        application/json:
          schema:
            type: object
            properties:
              detail:
                type: string
                example: Endpoint requires Basic tier or higher
  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

````