N=N_vect[indice]
    SNR=SNR_vect[indice]
    
    num=(sym.T*sym)
    sigmaB=np.sqrt(np.trace(num/2)/(np.power(10,SNR/10.)))
    
    print("SNR=%f, N=%d" % (SNR,N))
    
    for num_test in range(Ntest):
        
        for Nr_iterations in range(3):
            #Generate signal
            Y=generate_Y_from_sym(sym,w,N,sigmaB)
        
            #perform frequency estimation
            w0_est,trash,trash=estimate_w_NR_unbalanced(Y,w_init,Nr_iterations+1)
            sym_est=estimate_sym_unbalanced(Y,w0_est)
            f0_est=coef*w0_est
            #MSE for the frequency
            MSE[Nr_iterations,indice,0:6]=MSE[Nr_iterations,indice,0:6]+(sym.A1-sym_est.A1)**2
            MSE[Nr_iterations,indice,6]=MSE[Nr_iterations,indice,6]+(f0-f0_est)**2

    MSE[:,indice,:]=MSE[:,indice,:]/Ntest

    #Compute Cramer Rao Bounds
    CRB[indice,:]=compute_CRB_unbalanced(w,sym,N,sigmaB)
    CRB[indice,6]=(coef**2)*CRB[indice,6]
    CRB_approx[indice,:]=compute_CRB_unbalanced_approx(w,sym,N,sigmaB)
    CRB_approx[indice,6]=(coef**2)*CRB_approx[indice,6]

CRB_approx=np.zeros(7)

coef=(Fe/(2*np.pi))


num=(sym.T*sym)
sigmaB=np.sqrt(np.trace(num/2)/(np.power(10,SNR/10.)))
sym_mat=np.zeros((Ntest*3,2))

for num_test in range(Ntest):
    
    #Generate signal
    Y=generate_Y_from_sym(sym,w,N,sigmaB)
    
    #perform frequency estimation
    w0_est,trash,trash=estimate_w_NR_unbalanced(Y,w_init,3)
    sym_est=estimate_sym_unbalanced(Y,w0_est)
    sym_mat[num_test*3:(num_test+1)*3]=sym_est.reshape(3,2)




##export csv file
if csv_on==1:
    set1=['CRB exact','CRB approx','MSE Niter1','MSE Niter2', 'MSE Niter3']
    set2=['rz0','iz0','rz1','imz1','rz2','iz2','f']
    header=["%s %s"  %(x,y) for x in set1 for y in set2]
    header.insert(0,parameter)
    header_string=','.join(header)
    comments_string="Simulation Parameter: N=%d, SNR=%d, sym=%s, Fe=%d, f0=%f, Ntest=%d\n" % (N,SNR,sym.tolist(),Fe,f0,Ntest)