def capital_weights(preferred_stock, total_debt, common_stock):
    """
    Summary: Given a firm's capital structure, calculate the weights of each group.
    
    PARA total_capital: The company's total capital.
    PARA type: float
    
    PARA preferred_stock: The comapny's preferred stock outstanding.
    PARA type: float
    
    PARA common_stock: The comapny's common stock outstanding.
    PARA type: float
    
    PARA total_debt: The comapny's total debt.
    PARA type: float
    
    RTYP weights_dict: A dictionary of all the weights. 
    RTYP weights_dict: dictionary
    
    """      
    # initalize the dictionary
    weights_dict = {}
    
    # calculate the total capital
    total_capital = preferred_stock + common_stock + total_debt
    
    # calculate each weight and store it in the dictionary
    weights_dict['preferred_stock'] = preferred_stock / total_capital
    weights_dict['common_stock'] = common_stock / total_capital
    weights_dict['total_debt'] = total_debt / total_capital
    
    return weights_dict