calculate nBaseline
finished all the functions except for degenM,A,and B