def random_context_pos(self, num, num_permutations, context):
        """Samples with replacement available positions matching the
        sequence context.

        Note: this method does random sampling only for an individual
        sequence context.

        Parameters
        ----------
        num : int
            Number of positions to sample for each permutation. This
            is the number of actually observed mutations having the
            matching sequence context for this gene.
        num_permutations : int
            Number of permutations for permutation test.
        context : str
            Sequence context.

        Returns
        -------
        random_pos : np.array
            num_permutations X num sized array that represents the
            randomly sampled positions for a specific context.
        """
        # make sure provide context is valid
        if not self.is_valid_context(context):
            error_msg = 'Context ({0}) was never seen in sequence.'.format(context)
            raise ValueError(error_msg)

        # make sure sampling is a positive integer
        if num < 1:
            error_msg = ('There must be at least one sample (specified {0}) '
                         'for a context'.format(num))
            raise ValueError(error_msg)

        # randomly select from available positions that fit the specified context
        available_pos = self.context2pos[context]
        random_pos = self.prng_dict[context].choice(available_pos, (num_permutations, num))
        return random_pos