Composable Sketches for Functions of Frequencies: Beyond the Worst Case