$randomPosts = get_posts(array(
'orderby' => 'rand',
'posts_per_page' => 5,
'tag' => $tag,
));
Take a gander at the WP_Query
documentation. get_posts
uses WP_Query
under the hood, so you can use any arguments that may be used there.