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

# Stochastic Dominance Test

> Check if lottery A stochastically dominates lottery B. First-order stochastic dominance (FSD): A dominates B if F_A(x) ≤ F_B(x) for all x (preferred by all monotone utility functions). Second-order stochastic dominance (SSD): ∫F_A(t)dt ≤ ∫F_B(t)dt (preferred by all risk-averse utility functions). Returns boolean indicating dominance. Use for portfolio comparison and welfare ranking without specifying utility functions. [Tier: STANDARD, Credits: 2]



## OpenAPI

````yaml api-specs/economics.json post /quantlib/economics/utility/stochastic-dominance
openapi: 3.1.0
info:
  title: FinceptQuantLib API - Economics
  description: >-
    Economics module endpoints for FinceptQuantLib API - general equilibrium,
    game theory, auctions, and utility functions
  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-economics
    description: >-
      Economics module - general equilibrium, game theory, auctions, and utility
      theory
    x-displayName: Economics
paths:
  /quantlib/economics/utility/stochastic-dominance:
    post:
      tags:
        - quantlib-economics
      summary: Stochastic Dominance Test
      description: >-
        Check if lottery A stochastically dominates lottery B. First-order
        stochastic dominance (FSD): A dominates B if F_A(x) ≤ F_B(x) for all x
        (preferred by all monotone utility functions). Second-order stochastic
        dominance (SSD): ∫F_A(t)dt ≤ ∫F_B(t)dt (preferred by all risk-averse
        utility functions). Returns boolean indicating dominance. Use for
        portfolio comparison and welfare ranking without specifying utility
        functions. [Tier: STANDARD, Credits: 2]
      operationId: >-
        stochastic_dominance_quantlib_economics_utility_stochastic_dominance_post
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
                - cdf_a
                - cdf_b
              properties:
                cdf_a:
                  type: array
                  description: CDF of lottery A as [[x1, F_A(x1)], [x2, F_A(x2)], ...]
                  items:
                    type: array
                    items:
                      type: number
                    minItems: 2
                    maxItems: 2
                  minItems: 2
                  example:
                    - - 0
                      - 0
                    - - 5
                      - 0.3
                    - - 10
                      - 0.7
                    - - 15
                      - 1
                cdf_b:
                  type: array
                  description: CDF of lottery B as [[x1, F_B(x1)], [x2, F_B(x2)], ...]
                  items:
                    type: array
                    items:
                      type: number
                    minItems: 2
                    maxItems: 2
                  minItems: 2
                  example:
                    - - 0
                      - 0
                    - - 5
                      - 0.5
                    - - 10
                      - 0.9
                    - - 15
                      - 1
                order:
                  type: integer
                  description: Order of dominance (1 for FSD, 2 for SSD)
                  enum:
                    - 1
                    - 2
                  default: 1
                  example: 1
            example:
              cdf_a:
                - - 0
                  - 0
                - - 5
                  - 0.3
                - - 10
                  - 0.7
                - - 15
                  - 1
              cdf_b:
                - - 0
                  - 0
                - - 5
                  - 0.5
                - - 10
                  - 0.9
                - - 15
                  - 1
              order: 1
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      first_order_dominance_a_over_b:
                        type: boolean
                        description: >-
                          True if A first-order stochastically dominates B (only
                          for order=1)
                        example: true
                      second_order_dominance_a_over_b:
                        type: boolean
                        description: >-
                          True if A second-order stochastically dominates B
                          (only for order=2)
                        example: true
              example:
                success: true
                data:
                  first_order_dominance_a_over_b: true
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '402':
          $ref: '#/components/responses/InsufficientTierError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                type: object
                properties:
                  detail:
                    type: array
                    items:
                      type: object
              example:
                detail:
                  - loc:
                      - body
                      - cdf_a
                    msg: field required
                    type: value_error.missing
      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

````