In measure theory, the factorization lemma allows us to express a function f with another function T if f is measurable with respect to T. An application of this is regression analysis.
Let 
  
    
      
        T
        :
        Ω
        →
        
          Ω
          ′
        
      
    
    
   be a function of a set 
  
    
      
        Ω
      
    
    
   in a measure space 
  
    
      
        (
        
          Ω
          ′
        
        ,
        
          
            
              A
            
          
          ′
        
        )
      
    
    
   and let 
  
    
      
        f
        :
        Ω
        →
        
          
            
              R
            
            ¯
          
        
      
    
    
   be a scalar function on 
  
    
      
        Ω
      
    
    
  . Then 
  
    
      
        f
      
    
    
   is measurable with respect to the σ-algebra 
  
    
      
        σ
        (
        T
        )
        =
        
          T
          
            −
            1
          
        
        (
        
          
            
              A
            
          
          ′
        
        )
      
    
    
   generated by 
  
    
      
        T
      
    
    
   in 
  
    
      
        Ω
      
    
    
   if and only if there exists a measurable function 
  
    
      
        g
        :
        (
        
          Ω
          ′
        
        ,
        
          
            
              A
            
          
          ′
        
        )
        →
        (
        
          
            
              R
            
            ¯
          
        
        ,
        
          
            B
          
        
        (
        
          
            
              R
            
            ¯
          
        
        )
        )
      
    
    
   such that 
  
    
      
        f
        =
        g
        ∘
        T
      
    
    
  , where 
  
    
      
        
          
            B
          
        
        (
        
          
            
              R
            
            ¯
          
        
        )
      
    
    
   denotes the Borel set of the real numbers. If 
  
    
      
        f
      
    
    
   only takes finite values, then 
  
    
      
        g
      
    
    
   also only takes finite values.
First, if 
  
    
      
        f
        =
        g
        ∘
        T
      
    
    
  , then f is 
  
    
      
        σ
        (
        T
        )
        −
        
          
            B
          
        
        (
        
          
            
              R
            
            ¯
          
        
        )
      
    
    
   measurable because it is the composition of a 
  
    
      
        σ
        (
        T
        )
        −
        
          
            
              A
            
          
          ′
        
      
    
    
   and of a 
  
    
      
        
          
            
              A
            
          
          ′
        
        −
        
          
            B
          
        
        (
        
          
            
              R
            
            ¯
          
        
        )
      
    
    
   measurable function. The proof of the converse falls into four parts: (1)f is a step function, (2)f is a positive function, (3) f is any scalar function, (4) f only takes finite values.
Suppose 
  
    
      
        f
        =
        
          ∑
          
            i
            =
            1
          
          
            n
          
        
        
          α
          
            i
          
        
        
          1
          
            
              A
              
                i
              
            
          
        
      
    
    
   is a step function, i.e. 
  
    
      
        n
        ∈
        
          
            N
          
          
            ∗
          
        
        ,
        ∀
        i
        ∈
        [
        
        [
        1
        ,
        n
        ]
        
        ]
        ,
        
          A
          
            i
          
        
        ∈
        σ
        (
        T
        )
      
    
    
   and 
  
    
      
        
          α
          
            i
          
        
        ∈
        
          
            R
          
          
            +
          
        
      
    
    
  . As T is a measurable function, for all i, there exists 
  
    
      
        
          A
          
            i
          
          ′
        
        ∈
        
          
            
              A
            
          
          ′
        
      
    
    
   such that 
  
    
      
        
          A
          
            i
          
        
        =
        
          T
          
            −
            1
          
        
        (
        
          A
          
            i
          
          ′
        
        )
      
    
    
  . 
  
    
      
        g
        =
        
          ∑
          
            i
            =
            1
          
          
            n
          
        
        
          α
          
            i
          
        
        
          1
          
            
              A
              
                i
              
              ′
            
          
        
      
    
    
   fulfils the requirements.
If f takes only positive values, it is the limit, for pointwise convergence, of a increasing sequence 
  
    
      
        (
        
          u
          
            n
          
        
        
          )
          
            n
            ∈
            
              N
            
          
        
      
    
    
   of step functions. For each of these, by (1), there exists 
  
    
      
        
          g
          
            n
          
        
      
    
    
   such that 
  
    
      
        
          u
          
            n
          
        
        =
        
          g
          
            n
          
        
        ∘
        T
      
    
    
  . The function 
  
    
      
        
          lim
          
            n
            →
            +
            ∞
          
        
        
          g
          
            n
          
        
      
    
    
  , which exists on the image of T for pointwise convergence because 
  
    
      
        (
        
          u
          
            n
          
        
        
          )
          
            n
            ∈
            
              N
            
          
        
      
    
    
   is monotonic, fulfils the requirements.
We can decompose f in a positive part 
  
    
      
        
          f
          
            +
          
        
      
    
    
   and a negative part 
  
    
      
        
          f
          
            −
          
        
      
    
    
  . We can then find 
  
    
      
        
          g
          
            0
          
          
            +
          
        
      
    
    
   and 
  
    
      
        
          g
          
            0
          
          
            −
          
        
      
    
    
   such that 
  
    
      
        
          f
          
            +
          
        
        =
        
          g
          
            0
          
          
            +
          
        
        ∘
        T
      
    
    
   and 
  
    
      
        
          f
          
            −
          
        
        =
        
          g
          
            0
          
          
            −
          
        
        ∘
        T
      
    
    
  . The problem is that the difference 
  
    
      
        g
        :=
        
          g
          
            +
          
        
        −
        
          g
          
            −
          
        
      
    
    
   is not defined on the set 
  
    
      
        U
        =
        {
        x
        :
        
          g
          
            0
          
          
            +
          
        
        (
        x
        )
        =
        +
        ∞
        }
        ∩
        {
        x
        :
        
          g
          
            0
          
          
            −
          
        
        (
        x
        )
        =
        +
        ∞
        }
      
    
    
  . Fortunately, 
  
    
      
        T
        (
        Ω
        )
        ∩
        U
        =
        ∅
      
    
    
   because 
  
    
      
        
          g
          
            0
          
          
            +
          
        
        (
        T
        (
        ω
        )
        )
        =
        
          f
          
            +
          
        
        (
        ω
        )
        =
        +
        ∞
      
    
    
   always implies 
  
    
      
        
          g
          
            0
          
          
            −
          
        
        (
        T
        (
        ω
        )
        )
        =
        
          f
          
            −
          
        
        (
        ω
        )
        =
        0
      
    
    
   We define 
  
    
      
        
          g
          
            +
          
        
        =
        
          1
          
            
              Ω
              ′
            
            ∖
            U
          
        
        
          g
          
            0
          
          
            +
          
        
      
    
    
   and 
  
    
      
        
          g
          
            −
          
        
        =
        
          1
          
            
              Ω
              ′
            
            ∖
            U
          
        
        
          g
          
            0
          
          
            −
          
        
      
    
    
  . 
  
    
      
        g
        =
        
          g
          
            +
          
        
        −
        
          g
          
            −
          
        
      
    
    
   fulfils the requirements.
If f takes finite values only, we will show that g also only takes finite values. Let 
  
    
      
        
          U
          ′
        
        =
        {
        ω
        :
        
          |
        
        g
        (
        ω
        )
        
          |
        
        =
        +
        ∞
        }
      
    
    
  . Then 
  
    
      
        
          g
          
            0
          
        
        =
        
          1
          
            
              Ω
              ′
            
            ∖
            
              U
              ′
            
          
        
        g
      
    
    
   fulfils the requirements because 
  
    
      
        
          U
          ′
        
        ∩
        T
        (
        Ω
        )
        =
        ∅
      
    
    
  .
If the function 
  
    
      
        f
      
    
    
   is not scalar, but takes values in a different measurable space, such as 
  
    
      
        
          R
        
      
    
    
   with its trivial σ-algebra (the empty set, and the whole real line) instead of 
  
    
      
        
          
            B
          
        
        (
        
          R
        
        )
      
    
    
  , then the lemma becomes false (as the restrictions on 
  
    
      
        f
      
    
    
   are much weaker).