Write a function to parse a complex raw string containing player statistics and format it into a structured JSON object.
The input contains player records separated by ;, fields separated by |, and statistics stored as comma-separated key:value pairs after stats=. Return a Python dictionary with a players array, converting player_id and integer statistics to integers and decimal statistics to floats. Inputs are valid and contain player_id, name, team, and stats for every player.
def parse_player_stats(raw):