import math
import random


def random_dna(length, a=0.25, c=0.25, g=0.25, t=0.25):
	"""
	Generates random nucleotide sequence.

	Parameters
	----------
	+ length `int` nucleotide sequence
	+ a= `float` probability of A
	+ c= `float` probability of C
	+ g= `float` probability of G
	+ t= `float` probability of T
	"""

	assert(math.isclose(a+c+g+t, 1.0))
	seq = ''
	for i in range(length):
		r = random.random()
		if   r < a:     seq += 'A'
		elif r < a+c:   seq += 'C'
		elif r < a+c+g: seq += 'G'
		else:           seq += 'T'
	return seq