示例#1
0
def shut_time_pdf(mec, tres, tmin=0.00001, tmax=1000, points=512, unit='ms'):
    """
    Calculate ideal asymptotic and exact shut time distributions.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    ipdf, epdf, apdf : ndarrays of floats, shape (num of points)
        Ideal, exact and asymptotic shut time distributions.
    """

    open = False

    # Asymptotic pdf
    roots = scl.asymptotic_roots(tres, mec.QII, mec.QAA, mec.QIA, mec.QAI,
        mec.kI, mec.kA)

    tmax = (-1 / roots.max()) * 20
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    # Ideal pdf.
    eigs, w = scl.ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs)) # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    # Asymptotic pdf
    GAF, GFA = qml.iGs(mec.Q, mec.kA, mec.kI)
    areas = scl.asymptotic_areas(tres, roots,
        mec.QII, mec.QAA, mec.QIA, mec.QAI,
        mec.kI, mec.kA, GFA, GAF)
    apdf = scl.asymptotic_pdf(t, tres, -1 / roots, areas)

    # Exact pdf
    eigvals, gamma00, gamma10, gamma11 = scl.exact_GAMAxx(mec, tres, open)
    epdf = np.zeros(points)
    for i in range(points):
        epdf[i] = (t[i] * scl.exact_pdf(t[i], tres,
            roots, areas, eigvals, gamma00, gamma10, gamma11))

    if unit == 'ms':
        t = t * 1000 # x scale in millisec

    return t, ipdf, epdf, apdf
示例#2
0
def shut_time_pdf(mec, tres, tmin=0.00001, tmax=1000, points=512, unit='ms'):
    """
    Calculate ideal asymptotic and exact shut time distributions.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    ipdf, epdf, apdf : ndarrays of floats, shape (num of points)
        Ideal, exact and asymptotic shut time distributions.
    """

    open = False

    # Asymptotic pdf
    roots = scl.asymptotic_roots(tres, mec.QII, mec.QAA, mec.QIA, mec.QAI,
                                 mec.kI, mec.kA)

    tmax = (-1 / roots.max()) * 20
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    # Ideal pdf.
    eigs, w = scl.ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs))  # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    # Asymptotic pdf
    GAF, GFA = qml.iGs(mec.Q, mec.kA, mec.kI)
    areas = scl.asymptotic_areas(tres, roots, mec.QII, mec.QAA, mec.QIA,
                                 mec.QAI, mec.kI, mec.kA, GFA, GAF)
    apdf = scl.asymptotic_pdf(t, tres, -1 / roots, areas)

    # Exact pdf
    eigvals, gamma00, gamma10, gamma11 = scl.exact_GAMAxx(mec, tres, open)
    epdf = np.zeros(points)
    for i in range(points):
        epdf[i] = (t[i] * scl.exact_pdf(t[i], tres, roots, areas, eigvals,
                                        gamma00, gamma10, gamma11))

    if unit == 'ms':
        t = t * 1000  # x scale in millisec

    return t, ipdf, epdf, apdf
示例#3
0
def subset_time_pdf(mec,
                    tres,
                    state1,
                    state2,
                    tmin=0.00001,
                    tmax=1000,
                    points=512,
                    unit='ms'):
    """
    Calculate ideal pdf of any subset dwell times.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    state1, state2 : ints
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    spdf : ndarray of floats, shape (num of points)
        Subset dwell time pdf.
    """

    open = False
    if open:
        eigs, w = scl.ideal_dwell_time_pdf_components(mec.QAA, qml.phiA(mec))
    else:
        eigs, w = scl.ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))

    tmax = tau.max() * 20
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    # Ideal pdf.
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs))  # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    spdf = np.zeros(points)
    for i in range(points):
        spdf[i] = t[i] * scl.ideal_subset_time_pdf(mec.Q, state1, state2,
                                                   t[i]) * fac

    if unit == 'ms':
        t = t * 1000  # x scale in millisec

    return t, ipdf, spdf
示例#4
0
def subset_time_pdf(mec, tres, state1, state2,
    tmin=0.00001, tmax=1000, points=512, unit='ms'):
    """
    Calculate ideal pdf of any subset dwell times.

    Parameters
    ----------
    mec : instance of type Mechanism
    tres : float
        Time resolution.
    state1, state2 : ints
    tmin, tmax : floats
        Time range for burst length ditribution.
    points : int
        Number of points per plot.
    unit : str
        'ms'- milliseconds.

    Returns
    -------
    t : ndarray of floats, shape (num of points)
        Time in millisec.
    spdf : ndarray of floats, shape (num of points)
        Subset dwell time pdf.
    """

    open = False
    if open:
        eigs, w = scl.ideal_dwell_time_pdf_components(mec.QAA, qml.phiA(mec))
    else:
        eigs, w = scl.ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))

    tmax = tau.max() * 20
    t = np.logspace(math.log10(tmin), math.log10(tmax), points)

    # Ideal pdf.
    fac = 1 / np.sum((w / eigs) * np.exp(-tres * eigs)) # Scale factor
    ipdf = t * pdfs.expPDF(t, 1 / eigs, w / eigs) * fac

    spdf = np.zeros(points)
    for i in range(points):
        spdf[i] = t[i] * scl.ideal_subset_time_pdf(mec.Q,
            state1, state2, t[i]) * fac

    if unit == 'ms':
        t = t * 1000 # x scale in millisec

    return t, ipdf, spdf
示例#5
0
def corr_open_shut(mec, lag):
    """
    Calculate data for the plot of open, shut and open-shut time correlations.
    
    Parameters
    ----------
    mec : instance of type Mechanism
    lag : int
        Number of lags.

    Returns
    -------
    c : ndarray of floats, shape (num of points,)
        Concentration in mikroM
    br : ndarray of floats, shape (num of points,)
        Mean burst length in millisec.
    brblk : ndarray of floats, shape (num of points,)
        Mean burst length in millisec corrected for fast block.
    """
    
    kA, kF = mec.kA, mec.kI
    GAF, GFA = qml.iGs(mec.Q, kA, kF)
    XAA, XFF = np.dot(GAF, GFA), np.dot(GFA, GAF)
    phiA, phiF = qml.phiA(mec).reshape((1,kA)), qml.phiF(mec).reshape((1,kF))
    varA = scl.corr_variance_A(phiA, mec.QAA, kA)
    varF = scl.corr_variance_A(phiF, mec.QII, kF)
    
    r = np.arange(1, lag + 1)
    roA, roF, roAF = np.zeros(lag), np.zeros(lag), np.zeros(lag)
    for i in range(lag):
        covA = scl.corr_covariance_A(i+1, phiA, mec.QAA, XAA, kA)
        roA[i] = scl.correlation_coefficient(covA, varA, varA)
        covF = scl.corr_covariance_A(i+1, phiF, mec.QII, XFF, kF)
        roF[i] = scl.correlation_coefficient(covF, varF, varF)
        covAF = scl.corr_covariance_AF(i+1, phiA, mec.QAA, mec.QII,
            XAA, GAF, kA, kF)
        roAF[i] = scl.correlation_coefficient(covAF, varA, varF)
            
    return r, roA, roF, roAF
示例#6
0
def corr_open_shut(mec, lag):
    """
    Calculate data for the plot of open, shut and open-shut time correlations.
    
    Parameters
    ----------
    mec : instance of type Mechanism
    lag : int
        Number of lags.

    Returns
    -------
    c : ndarray of floats, shape (num of points,)
        Concentration in mikroM
    br : ndarray of floats, shape (num of points,)
        Mean burst length in millisec.
    brblk : ndarray of floats, shape (num of points,)
        Mean burst length in millisec corrected for fast block.
    """

    kA, kF = mec.kA, mec.kI
    GAF, GFA = qml.iGs(mec.Q, kA, kF)
    XAA, XFF = np.dot(GAF, GFA), np.dot(GFA, GAF)
    phiA, phiF = qml.phiA(mec).reshape((1, kA)), qml.phiF(mec).reshape((1, kF))
    varA = scl.corr_variance_A(phiA, mec.QAA, kA)
    varF = scl.corr_variance_A(phiF, mec.QII, kF)

    r = np.arange(1, lag + 1)
    roA, roF, roAF = np.zeros(lag), np.zeros(lag), np.zeros(lag)
    for i in range(lag):
        covA = scl.corr_covariance_A(i + 1, phiA, mec.QAA, XAA, kA)
        roA[i] = scl.correlation_coefficient(covA, varA, varA)
        covF = scl.corr_covariance_A(i + 1, phiF, mec.QII, XFF, kF)
        roF[i] = scl.correlation_coefficient(covF, varF, varF)
        covAF = scl.corr_covariance_AF(i + 1, phiA, mec.QAA, mec.QII, XAA, GAF,
                                       kA, kF)
        roAF[i] = scl.correlation_coefficient(covAF, varA, varF)

    return r, roA, roF, roAF
示例#7
0
    def test_openshut(self):

        # # # Initial HJC vectors.
        expQFF = qml.expQt(self.mec.QFF, self.tres)
        expQAA = qml.expQt(self.mec.QAA, self.tres)
        GAF, GFA = qml.iGs(self.mec.Q, self.mec.kA, self.mec.kF)
        eGAF = qml.eGs(GAF, GFA, self.mec.kA, self.mec.kF, expQFF)
        eGFA = qml.eGs(GFA, GAF, self.mec.kF, self.mec.kA, expQAA)
        phiA = qml.phiHJC(eGAF, eGFA, self.mec.kA)
        phiF = qml.phiHJC(eGFA, eGAF, self.mec.kF)

        self.assertAlmostEqual(phiA[0], 0.153966, 6)
        self.assertAlmostEqual(phiA[1], 0.846034, 6)
        self.assertAlmostEqual(phiF[0], 0.530369, 6)
        self.assertAlmostEqual(phiF[1], 0.386116, 6)
        self.assertAlmostEqual(phiF[2], 0.0835153, 6)

        # Ideal shut time pdf
        eigs, w = scl.ideal_dwell_time_pdf_components(self.mec.QFF,
                                                      qml.phiF(self.mec))
        self.assertAlmostEqual(eigs[0], 0.263895, 6)
        self.assertAlmostEqual(eigs[1], 2062.93, 2)
        self.assertAlmostEqual(eigs[2], 19011.8, 1)
        self.assertAlmostEqual(w[0], 0.0691263, 6)
        self.assertAlmostEqual(w[1], 17.2607, 4)
        self.assertAlmostEqual(w[2], 13872.7, 1)

        # Asymptotic shut time pdf
        roots = scl.asymptotic_roots(self.tres, self.mec.QFF, self.mec.QAA,
                                     self.mec.QFA, self.mec.QAF, self.mec.kF,
                                     self.mec.kA)
        areas = scl.asymptotic_areas(self.tres, roots, self.mec.QFF,
                                     self.mec.QAA, self.mec.QFA, self.mec.QAF,
                                     self.mec.kF, self.mec.kA, GFA, GAF)
        mean = scl.exact_mean_time(self.tres, self.mec.QFF, self.mec.QAA,
                                   self.mec.QFA, self.mec.kF, self.mec.kA, GFA,
                                   GAF)
        self.assertAlmostEqual(-roots[0], 17090.2, 1)
        self.assertAlmostEqual(-roots[1], 2058.08, 2)
        self.assertAlmostEqual(-roots[2], 0.243565, 6)
        self.assertAlmostEqual(areas[0] * 100, 28.5815, 4)
        self.assertAlmostEqual(areas[1] * 100, 1.67311, 5)
        self.assertAlmostEqual(areas[2] * 100, 68.3542, 4)

        # Exact pdf
        eigvals, gamma00, gamma10, gamma11 = scl.exact_GAMAxx(
            self.mec, self.tres, False)
        self.assertAlmostEqual(gamma00[0], 0.940819, 6)
        self.assertAlmostEqual(gamma00[1], 117.816, 3)
        self.assertAlmostEqual(gamma00[2], 24.8962, 4)
        self.assertAlmostEqual(gamma00[3], 1.28843, 5)
        self.assertAlmostEqual(gamma00[4], 5370.18, 2)
        self.assertAlmostEqual(gamma10[0], 4.57792, 5)
        self.assertAlmostEqual(gamma10[1], 100.211, 3)
        self.assertAlmostEqual(gamma10[2], -5.49855, 4)
        self.assertAlmostEqual(gamma10[3], 0.671548, 6)
        self.assertAlmostEqual(gamma10[4], -99.9617, 4)
        self.assertAlmostEqual(gamma11[0], 0.885141, 6)
        self.assertAlmostEqual(gamma11[1], 43634.99, 1)
        self.assertAlmostEqual(gamma11[2], 718.068, 3)
        self.assertAlmostEqual(gamma11[3], -39.7437, 3)
        self.assertAlmostEqual(gamma11[4], -1.9832288e+06, 0)
示例#8
0
def printout_correlations(mec, output=sys.stdout, eff='c'):
    """

    """

    str = ('\n\n*************************************\n' + 'CORRELATIONS\n')

    kA, kI = mec.kA, mec.kI
    str += ('kA, kF = {0:d}, {1:d}\n'.format(kA, kI))
    GAF, GFA = qml.iGs(mec.Q, kA, kI)
    rGAF, rGFA = np.rank(GAF), np.rank(GFA)
    str += ('Ranks of GAF, GFA = {0:d}, {1:d}\n'.format(rGAF, rGFA))
    XFF = np.dot(GFA, GAF)
    rXFF = np.rank(XFF)
    str += ('Rank of GFA * GAF = {0:d}\n'.format(rXFF))
    ncF = rXFF - 1
    eigXFF, AXFF = qml.eigs(XFF)
    str += ('Eigenvalues of GFA * GAF:\n')
    str1 = ''
    for i in range(kI):
        str1 += '\t{0:.5g}'.format(eigXFF[i])
    str += str1 + '\n'
    XAA = np.dot(GAF, GFA)
    rXAA = np.rank(XAA)
    str += ('Rank of GAF * GFA = {0:d}\n'.format(rXAA))
    ncA = rXAA - 1
    eigXAA, AXAA = qml.eigs(XAA)
    str += ('Eigenvalues of GAF * GFA:\n')
    str1 = ''
    for i in range(kA):
        str1 += '\t{0:.5g}'.format(eigXAA[i])
    str += str1 + '\n'
    phiA, phiF = qml.phiA(mec).reshape((1, kA)), qml.phiF(mec).reshape((1, kI))
    varA = corr_variance_A(phiA, mec.QAA, kA)
    varF = corr_variance_A(phiF, mec.QII, kI)

    #   open - open time correlations
    str += ('\n OPEN - OPEN TIME CORRELATIONS')
    str += ('Variance of open time = {0:.5g}\n'.format(varA))
    SDA = sqrt(varA)
    str += ('SD of all open times = {0:.5g} ms\n'.format(SDA * 1000))
    n = 50
    SDA_mean_n = SDA / sqrt(float(n))
    str += ('SD of means of {0:d} open times if'.format(n) +
            'uncorrelated = {0:.5g} ms\n'.format(SDA_mean_n * 1000))
    covAtot = 0
    for i in range(1, n):
        covA = corr_covariance_A(i + 1, phiA, mec.QAA, XAA, kA)
        ro = correlation_coefficient(covA, varA, varA)
        covAtot += (n - i) * ro * varA
    vtot = n * varA + 2. * covAtot
    actSDA = sqrt(vtot / (n * n))
    str += ('Actual SD of mean = {0:.5g} ms\n'.format(actSDA * 1000))
    pA = 100 * (actSDA - SDA_mean_n) / SDA_mean_n
    str += (
        'Percent difference as result of correlation = {0:.5g}\n'.format(pA))
    v2A = corr_limit_A(phiA, mec.QAA, AXAA, eigXAA, kA)
    pmaxA = 100 * (sqrt(1 + 2 * v2A / varA) - 1)
    str += ('Limiting value of percent difference for large n = {0:.5g}\n'.
            format(pmaxA))
    str += ('Correlation coefficients, r(k), for up to lag k = 5:\n')
    for i in range(5):
        covA = corr_covariance_A(i + 1, phiA, mec.QAA, XAA, kA)
        ro = correlation_coefficient(covA, varA, varA)
        str += ('r({0:d}) = {1:.5g}\n'.format(i + 1, ro))

    # shut - shut time correlations
    str += ('\n SHUT - SHUT TIME CORRELATIONS\n')
    str += ('Variance of shut time = {0:.5g}\n'.format(varF))
    SDF = sqrt(varF)
    str += ('SD of all shut times = {0:.5g} ms\n'.format(SDF * 1000))
    n = 50
    SDF_mean_n = SDF / sqrt(float(n))
    str += ('SD of means of {0:d} shut times if'.format(n) +
            'uncorrelated = {0:.5g} ms\n'.format(SDF_mean_n * 1000))
    covFtot = 0
    for i in range(1, n):
        covF = corr_covariance_A(i + 1, phiF, mec.QII, XFF, kI)
        ro = correlation_coefficient(covF, varF, varF)
        covFtot += (n - i) * ro * varF
    vtotF = 50 * varF + 2. * covFtot
    actSDF = sqrt(vtotF / (50. * 50.))
    str += ('Actual SD of mean = {0:.5g} ms\n'.format(actSDF * 1000))
    pF = 100 * (actSDF - SDF_mean_n) / SDF_mean_n
    str += (
        'Percent difference as result of correlation = {0:.5g}\n'.format(pF))
    v2F = corr_limit_A(phiF, mec.QII, AXFF, eigXFF, kI)
    pmaxF = 100 * (sqrt(1 + 2 * v2F / varF) - 1)
    str += ('Limiting value of percent difference for large n = {0:.5g}\n'.
            format(pmaxF))
    str += ('Correlation coefficients, r(k), for up to k = 5 lags:\n')
    for i in range(5):
        covF = corr_covariance_A(i + 1, phiF, mec.QII, XFF, kI)
        ro = correlation_coefficient(covF, varF, varF)
        str += ('r({0:d}) = {1:.5g}\n'.format(i + 1, ro))

    # open - shut time correlations
    str += ('\n OPEN - SHUT TIME CORRELATIONS\n')
    str += ('Correlation coefficients, r(k), for up to k= 5 lags:\n')
    for i in range(5):
        covAF = corr_covariance_AF(i + 1, phiA, mec.QAA, mec.QII, XAA, GAF, kA,
                                   kI)
        ro = correlation_coefficient(covAF, varA, varF)
        str += ('r({0:d}) = {1:.5g}\n'.format(i + 1, ro))
    return str
示例#9
0
def printout_distributions(mec, tres, eff='c'):
    """

    """

    str = '\n*******************************************\n'
    GAI, GIA = qml.iGs(mec.Q, mec.kA, mec.kI)
    # OPEN TIME DISTRIBUTIONS
    open = True
    # Ideal pdf
    eigs, w = ideal_dwell_time_pdf_components(mec.QAA, qml.phiA(mec))
    str += 'IDEAL OPEN TIME DISTRIBUTION\n'
    str += pdfs.expPDF_printout(eigs, w)

    # Asymptotic pdf
    #roots = asymptotic_roots(mec, tres, open)
    roots = asymptotic_roots(tres, mec.QAA, mec.QII, mec.QAI, mec.QIA, mec.kA,
                             mec.kI)
    #areas = asymptotic_areas(mec, tres, roots, open)
    areas = asymptotic_areas(tres, roots, mec.QAA, mec.QII, mec.QAI, mec.QIA,
                             mec.kA, mec.kI, GAI, GIA)
    str += '\nASYMPTOTIC OPEN TIME DISTRIBUTION\n'
    str += 'term\ttau (ms)\tarea (%)\trate const (1/sec)\n'
    for i in range(mec.kA):
        str += ('{0:d}'.format(i + 1) +
                '\t{0:.5g}'.format(-1.0 / roots[i] * 1000) +
                '\t{0:.5g}'.format(areas[i] * 100) +
                '\t{0:.5g}\n'.format(-roots[i]))
    areast0 = np.zeros(mec.kA)
    for i in range(mec.kA):
        areast0[i] = areas[i] * np.exp(-tres * roots[i])
    areast0 = areast0 / np.sum(areast0)
    str += ('Areas for asymptotic pdf renormalised for t=0 to\
    infinity (and sum=1), so areas can be compared with ideal pdf.\n')
    for i in range(mec.kA):
        str += ('{0:d}'.format(i + 1) + '\t{0:.5g}\n'.format(areast0[i] * 100))
    mean = exact_mean_time(tres, mec.QAA, mec.QII, mec.QAI, mec.kA, mec.kI,
                           GAI, GIA)
    str += ('Mean open time (ms) = {0:.5g}\n'.format(mean * 1000))

    # Exact pdf
    eigvals, gamma00, gamma10, gamma11 = exact_GAMAxx(mec, tres, open)
    str += ('\nEXACT OPEN TIME DISTRIBUTION\n')
    str += ('eigen\tg00(m)\tg10(m)\tg11(m)\n')
    for i in range(mec.k):
        str += ('{0:.5g}'.format(eigvals[i]) + '\t{0:.5g}'.format(gamma00[i]) +
                '\t{0:.5g}'.format(gamma10[i]) +
                '\t{0:.5g}\n'.format(gamma11[i]))

    str += ('\n\n*******************************************\n')
    # SHUT TIME DISTRIBUTIONS
    open = False
    # Ideal pdf
    eigs, w = ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))
    str += ('IDEAL SHUT TIME DISTRIBUTION\n')
    str += pdfs.expPDF_printout(eigs, w)

    # Asymptotic pdf
    #roots = asymptotic_roots(mec, tres, open)
    roots = asymptotic_roots(tres, mec.QII, mec.QAA, mec.QIA, mec.QAI, mec.kI,
                             mec.kA)
    #areas = asymptotic_areas(mec, tres, roots, open)
    areas = asymptotic_areas(tres, roots, mec.QII, mec.QAA, mec.QIA, mec.QAI,
                             mec.kI, mec.kA, GIA, GAI)
    str += ('\nASYMPTOTIC SHUT TIME DISTRIBUTION\n')
    str += ('term\ttau (ms)\tarea (%)\trate const (1/sec)\n')
    for i in range(mec.kI):
        str += ('{0:d}'.format(i + 1) +
                '\t{0:.5g}'.format(-1.0 / roots[i] * 1000) +
                '\t{0:.5g}'.format(areas[i] * 100) +
                '\t{0:.5g}\n'.format(-roots[i]))
    areast0 = np.zeros(mec.kI)
    for i in range(mec.kI):
        areast0[i] = areas[i] * np.exp(-tres * roots[i])
    areast0 = areast0 / np.sum(areast0)
    str += ('Areas for asymptotic pdf renormalised for t=0 to\
    infinity (and sum=1), so areas can be compared with ideal pdf.\n')
    for i in range(mec.kI):
        str += ('{0:d}'.format(i + 1) + '\t{0:.5g}\n'.format(areast0[i] * 100))
    mean = exact_mean_time(tres, mec.QII, mec.QAA, mec.QIA, mec.kI, mec.kA,
                           GIA, GAI)
    str += ('Mean shut time (ms) = {0:.6f}\n'.format(mean * 1000))

    # Exact pdf
    eigvals, gamma00, gamma10, gamma11 = exact_GAMAxx(mec, tres, open)
    str += ('\nEXACT SHUT TIME DISTRIBUTION\n' +
            'eigen\tg00(m)\tg10(m)\tg11(m)\n')
    for i in range(mec.k):
        str += ('{0:.5g}'.format(eigvals[i]) + '\t{0:.5g}'.format(gamma00[i]) +
                '\t{0:.5g}'.format(gamma10[i]) +
                '\t{0:.5g}\n'.format(gamma11[i]))

    # Transition probabilities
    pi = transition_probability(mec.Q)
    str += ('\nProbability of transitions regardless of time:\n')
    for i in range(mec.k):
        str1 = '['
        for j in range(mec.k):
            str1 += '{0:.4g}\t'.format(pi[i, j])
        str1 += ']\n'
        str += str1

    # Transition frequency
    f = transition_frequency(mec.Q)
    str += ('\nFrequency of transitions (per second):\n')
    for i in range(mec.k):
        str1 = '['
        for j in range(mec.k):
            str1 += '{0:.4g}\t'.format(f[i, j])
        str1 += ']\n'
        str += str1

    return str
示例#10
0
def printout_tcrit(mec):
    """
    Output calculations based on division into bursts by critical time (tcrit).

    Parameters
    ----------
    mec : dcpyps.Mechanism
        The mechanism to be analysed.
    output : output device
        Default device: sys.stdout
    """

    str = ('\n\n*******************************************\n' +
           'CALCULATIONS BASED ON DIVISION INTO BURSTS BY' +
           ' tcrit- CRITICAL TIME.\n')
    # Ideal shut time pdf
    eigs, w = ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))
    str += ('\nIDEAL SHUT TIME DISTRIBUTION\n')
    str += pdfs.expPDF_printout(eigs, w)
    taus = 1 / eigs
    areas = w / eigs
    taus, areas = sortShell2(taus, areas)

    comps = taus.shape[0] - 1
    tcrits = np.empty((3, comps))
    for i in range(comps):
        str += ('\nCritical time between components {0:d} and {1:d}\n'.format(
            i + 1, i + 2) + '\nEqual % misclassified (DC criterion)\n')
        try:
            tcrit = so.bisect(pdfs.expPDF_tcrit_DC,
                              taus[i],
                              taus[i + 1],
                              args=(taus, areas, i + 1))
            enf, ens, pf, ps = pdfs.expPDF_misclassified(
                tcrit, taus, areas, i + 1)
            str += pdfs.expPDF_misclassified_printout(tcrit, enf, ens, pf, ps)
        except:
            str += ('Bisection with DC criterion failed.\n')
            tcrit = None
        tcrits[0, i] = tcrit

        str += ('\nEqual # misclassified (Clapham & Neher criterion)\n')
        try:
            tcrit = so.bisect(pdfs.expPDF_tcrit_CN,
                              taus[i],
                              taus[i + 1],
                              args=(taus, areas, i + 1))
            enf, ens, pf, ps = pdfs.expPDF_misclassified(
                tcrit, taus, areas, i + 1)
            str += pdfs.expPDF_misclassified_printout(tcrit, enf, ens, pf, ps)
        except:
            str += ('Bisection with Clapham & Neher criterion failed.\n')
            tcrit = None
        tcrits[1, i] = tcrit

        str += ('\nMinimum total # misclassified (Jackson et al criterion)')
        try:
            tcrit = so.bisect(pdfs.expPDF_tcrit_Jackson,
                              taus[i],
                              taus[i + 1],
                              args=(taus, areas, i + 1))
            enf, ens, pf, ps = pdfs.expPDF_misclassified(
                tcrit, taus, areas, i + 1)
            str += pdfs.expPDF_misclassified_printout(tcrit, enf, ens, pf, ps)
        except:
            str += ('\nBisection with Jackson et al criterion failed.')
            tcrit = None
        tcrits[2, i] = tcrit

    str += ('\nSUMMARY of tcrit values:\n' + 'Components  DC\tC&N\tJackson\n')
    for i in range(comps):
        str += ('{0:d} to {1:d} '.format(i + 1, i + 2) +
                '\t{0:.5g}'.format(tcrits[0, i] * 1000) +
                '\t{0:.5g}'.format(tcrits[1, i] * 1000) +
                '\t{0:.5g}\n'.format(tcrits[2, i] * 1000))

    return str
示例#11
0
def printout_occupancies(mec, tres):
    """
    """

    str = ('\n\n\n*******************************************\n\n' +
           'Open\tEquilibrium\tMean life\tMean latency (ms)\n' +
           'state\toccupancy\t(ms)\tto next shutting\n' +
           '\t\t\tgiven start in this state\n')

    pinf = qml.pinf(mec.Q)

    for i in range(mec.k):
        if i == 0:
            mean_life_A = ideal_subset_mean_life_time(mec.Q, 1, mec.kA)
            str += ('Subset A ' + '\t{0:.5g}'.format(np.sum(pinf[:mec.kA])) +
                    '\t{0:.5g}\n'.format(mean_life_A * 1000))
        if i == mec.kA:
            mean_life_B = ideal_subset_mean_life_time(mec.Q, mec.kA + 1,
                                                      mec.kE)
            str += ('\nShut\tEquilibrium\tMean life\tMean latency (ms)\n' +
                    'state\toccupancy\t(ms)\tto next opening\n' +
                    '\t\t\tgiven start in this state\n' + 'Subset B ' +
                    '\t{0:.5g}'.format(np.sum(pinf[mec.kA:mec.kE])) +
                    '\t{0:.5g}\n'.format(mean_life_B * 1000))
        if i == mec.kE:
            mean_life_C = ideal_subset_mean_life_time(mec.Q, mec.kE + 1,
                                                      mec.kG)
            str += ('\nSubset C ' +
                    '\t{0:.5g}'.format(np.sum(pinf[mec.kE:mec.kG])) +
                    '\t{0:.5g}\n'.format(mean_life_C * 1000))
        if i == mec.kG:
            mean_life_D = ideal_subset_mean_life_time(mec.Q, mec.kG + 1, mec.k)
            str += ('\nSubset D ' +
                    '\t{0:.5g}'.format(np.sum(pinf[mec.kG:mec.k])) +
                    '\t{0:.5g}\n'.format(mean_life_D * 1000))

        mean = ideal_mean_latency_given_start_state(mec, i + 1)
        str += ('{0:d}'.format(i + 1) + '\t{0:.5g}'.format(pinf[i]) +
                '\t{0:.5g}'.format(-1 / mec.Q[i, i] * 1000) +
                '\t{0:.5g}\n'.format(mean * 1000))

    expQFF = qml.expQt(mec.QFF, tres)
    expQAA = qml.expQt(mec.QAA, tres)
    GAF, GFA = qml.iGs(mec.Q, mec.kA, mec.kF)
    eGAF = qml.eGs(GAF, GFA, mec.kA, mec.kF, expQFF)
    eGFA = qml.eGs(GFA, GAF, mec.kF, mec.kA, expQAA)
    phiA = qml.phiHJC(eGAF, eGFA, mec.kA)
    phiF = qml.phiHJC(eGFA, eGAF, mec.kF)

    str += ('\n\nInitial vector for HJC openings phiOp =\n')
    for i in range(phiA.shape[0]):
        str += ('\t{0:.5g}'.format(phiA[i]))
    str += ('\nInitial vector for ideal openings phiOp =\n')
    phiAi = qml.phiA(mec)
    for i in range(phiA.shape[0]):
        str += ('\t{0:.5g}'.format(phiAi[i]))
    str += ('\nInitial vector for HJC shuttings phiSh =\n')
    for i in range(phiF.shape[0]):
        str += ('\t{0:.5g}'.format(phiF[i]))
    str += ('\nInitial vector for ideal shuttings phiSh =\n')
    phiFi = qml.phiF(mec)
    for i in range(phiF.shape[0]):
        str += ('\t{0:.5g}'.format(phiFi[i]))
    str += '\n'

    return str
示例#12
0
def printout_correlations(mec, output=sys.stdout, eff='c'):
    """

    """

    str = ('\n\n*************************************\n' +
        'CORRELATIONS\n')
    
    kA, kI = mec.kA, mec.kI
    str += ('kA, kF = {0:d}, {1:d}\n'.format(kA, kI))
    GAF, GFA = qml.iGs(mec.Q, kA, kI)
    rGAF, rGFA = np.rank(GAF), np.rank(GFA)
    str += ('Ranks of GAF, GFA = {0:d}, {1:d}\n'.format(rGAF, rGFA))
    XFF = np.dot(GFA, GAF)
    rXFF = np.rank(XFF)
    str += ('Rank of GFA * GAF = {0:d}\n'.format(rXFF))
    ncF = rXFF - 1
    eigXFF, AXFF = qml.eigs(XFF)
    str += ('Eigenvalues of GFA * GAF:\n')
    str1 = ''
    for i in range(kI):
        str1 += '\t{0:.5g}'.format(eigXFF[i])
    str += str1 + '\n'
    XAA = np.dot(GAF, GFA)
    rXAA = np.rank(XAA)
    str += ('Rank of GAF * GFA = {0:d}\n'.format(rXAA))
    ncA = rXAA - 1
    eigXAA, AXAA = qml.eigs(XAA)
    str += ('Eigenvalues of GAF * GFA:\n')
    str1 = ''
    for i in range(kA):
        str1 += '\t{0:.5g}'.format(eigXAA[i])
    str += str1 + '\n'
    phiA, phiF = qml.phiA(mec).reshape((1,kA)), qml.phiF(mec).reshape((1,kI))
    varA = corr_variance_A(phiA, mec.QAA, kA)
    varF = corr_variance_A(phiF, mec.QII, kI)
    
    #   open - open time correlations
    str += ('\n OPEN - OPEN TIME CORRELATIONS')
    str += ('Variance of open time = {0:.5g}\n'.format(varA))
    SDA = sqrt(varA)
    str += ('SD of all open times = {0:.5g} ms\n'.format(SDA * 1000))
    n = 50
    SDA_mean_n = SDA / sqrt(float(n))
    str += ('SD of means of {0:d} open times if'.format(n) + 
        'uncorrelated = {0:.5g} ms\n'.format(SDA_mean_n * 1000))
    covAtot = 0
    for i in range(1, n):
        covA = corr_covariance_A(i+1, phiA, mec.QAA, XAA, kA)
        ro = correlation_coefficient(covA, varA, varA)
        covAtot += (n - i) * ro * varA
    vtot = n * varA + 2. * covAtot
    actSDA = sqrt(vtot / (n * n))
    str += ('Actual SD of mean = {0:.5g} ms\n'.format(actSDA * 1000))
    pA = 100 * (actSDA - SDA_mean_n) / SDA_mean_n
    str += ('Percent difference as result of correlation = {0:.5g}\n'.
        format(pA))
    v2A = corr_limit_A(phiA, mec.QAA, AXAA, eigXAA, kA)
    pmaxA = 100 * (sqrt(1 + 2 * v2A / varA) - 1)
    str += ('Limiting value of percent difference for large n = {0:.5g}\n'.
        format(pmaxA))
    str += ('Correlation coefficients, r(k), for up to lag k = 5:\n')
    for i in range(5):
        covA = corr_covariance_A(i+1, phiA, mec.QAA, XAA, kA)
        ro = correlation_coefficient(covA, varA, varA)
        str += ('r({0:d}) = {1:.5g}\n'.format(i+1, ro))

    # shut - shut time correlations
    str += ('\n SHUT - SHUT TIME CORRELATIONS\n')
    str += ('Variance of shut time = {0:.5g}\n'.format(varF))
    SDF = sqrt(varF)
    str += ('SD of all shut times = {0:.5g} ms\n'.format(SDF * 1000))
    n = 50
    SDF_mean_n = SDF / sqrt(float(n))
    str += ('SD of means of {0:d} shut times if'.format(n) +
        'uncorrelated = {0:.5g} ms\n'.format(SDF_mean_n * 1000))
    covFtot = 0
    for i in range(1, n):
        covF = corr_covariance_A(i+1, phiF, mec.QII, XFF, kI)
        ro = correlation_coefficient(covF, varF, varF)
        covFtot += (n - i) * ro * varF
    vtotF = 50 * varF + 2. * covFtot
    actSDF = sqrt(vtotF / (50. * 50.))
    str += ('Actual SD of mean = {0:.5g} ms\n'.format(actSDF * 1000))
    pF = 100 * (actSDF - SDF_mean_n) / SDF_mean_n
    str += ('Percent difference as result of correlation = {0:.5g}\n'.
        format(pF))
    v2F = corr_limit_A(phiF, mec.QII, AXFF, eigXFF, kI)
    pmaxF = 100 * (sqrt(1 + 2 * v2F / varF) - 1)
    str += ('Limiting value of percent difference for large n = {0:.5g}\n'.
        format(pmaxF))
    str += ('Correlation coefficients, r(k), for up to k = 5 lags:\n')
    for i in range(5):
        covF = corr_covariance_A(i+1, phiF, mec.QII, XFF, kI)
        ro = correlation_coefficient(covF, varF, varF)
        str += ('r({0:d}) = {1:.5g}\n'.format(i+1, ro))

    # open - shut time correlations 
    str += ('\n OPEN - SHUT TIME CORRELATIONS\n')
    str += ('Correlation coefficients, r(k), for up to k= 5 lags:\n')
    for i in range(5):
        covAF = corr_covariance_AF(i+1, phiA, mec.QAA, mec.QII, XAA, GAF, kA, kI)
        ro = correlation_coefficient(covAF, varA, varF)
        str += ('r({0:d}) = {1:.5g}\n'.format(i+1, ro))
    return str
示例#13
0
def printout_tcrit(mec):
    """
    Output calculations based on division into bursts by critical time (tcrit).

    Parameters
    ----------
    mec : dcpyps.Mechanism
        The mechanism to be analysed.
    output : output device
        Default device: sys.stdout
    """

    str = ('\n\n*******************************************\n' +
        'CALCULATIONS BASED ON DIVISION INTO BURSTS BY' +
        ' tcrit- CRITICAL TIME.\n')
    # Ideal shut time pdf
    eigs, w = ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))
    str += ('\nIDEAL SHUT TIME DISTRIBUTION\n')
    str += pdfs.expPDF_printout(eigs, w)
    taus = 1 / eigs
    areas = w /eigs
    taus, areas = sortShell2(taus, areas)

    comps = taus.shape[0]-1
    tcrits = np.empty((3, comps))
    for i in range(comps):
        str += ('\nCritical time between components {0:d} and {1:d}\n'.
            format(i+1, i+2) + '\nEqual % misclassified (DC criterion)\n')
        try:
            tcrit = so.bisect(pdfs.expPDF_tcrit_DC,
                taus[i], taus[i+1], args=(taus, areas, i+1))
            enf, ens, pf, ps = pdfs.expPDF_misclassified(tcrit, taus, areas, i+1)
            str += pdfs.expPDF_misclassified_printout(tcrit, enf, ens, pf, ps)
        except:
            str += ('Bisection with DC criterion failed.\n')
            tcrit = None
        tcrits[0, i] = tcrit
        
        str += ('\nEqual # misclassified (Clapham & Neher criterion)\n')
        try:
            tcrit = so.bisect(pdfs.expPDF_tcrit_CN,
                taus[i], taus[i+1], args=(taus, areas, i+1))
            enf, ens, pf, ps = pdfs.expPDF_misclassified(tcrit, taus, areas, i+1)
            str += pdfs.expPDF_misclassified_printout(tcrit, enf, ens, pf, ps)
        except:
            str += ('Bisection with Clapham & Neher criterion failed.\n')
            tcrit = None
        tcrits[1, i] = tcrit
        
        str += ('\nMinimum total # misclassified (Jackson et al criterion)')
        try:
            tcrit = so.bisect(pdfs.expPDF_tcrit_Jackson,
                taus[i], taus[i+1], args=(taus, areas, i+1))
            enf, ens, pf, ps = pdfs.expPDF_misclassified(tcrit, taus, areas, i+1)
            str += pdfs.expPDF_misclassified_printout(tcrit, enf, ens, pf, ps)
        except:
            str += ('\nBisection with Jackson et al criterion failed.')
            tcrit = None
        tcrits[2, i] = tcrit
        
    str += ('\nSUMMARY of tcrit values:\n' +
        'Components  DC\tC&N\tJackson\n')
    for i in range(comps):
        str += ('{0:d} to {1:d} '.format(i+1, i+2) +
            '\t{0:.5g}'.format(tcrits[0, i] * 1000) +
            '\t{0:.5g}'.format(tcrits[1, i] * 1000) +
            '\t{0:.5g}\n'.format(tcrits[2, i] * 1000))
            
    return str
示例#14
0
def printout_distributions(mec, tres, eff='c'):
    """

    """

    str = '\n*******************************************\n'
    GAI, GIA = qml.iGs(mec.Q, mec.kA, mec.kI)
    # OPEN TIME DISTRIBUTIONS
    open = True
    # Ideal pdf
    eigs, w = ideal_dwell_time_pdf_components(mec.QAA,
        qml.phiA(mec))
    str += 'IDEAL OPEN TIME DISTRIBUTION\n'
    str += pdfs.expPDF_printout(eigs, w)

    # Asymptotic pdf
    #roots = asymptotic_roots(mec, tres, open)
    roots = asymptotic_roots(tres,
        mec.QAA, mec.QII, mec.QAI, mec.QIA, mec.kA, mec.kI)
    #areas = asymptotic_areas(mec, tres, roots, open)
    areas = asymptotic_areas(tres, roots,
        mec.QAA, mec.QII, mec.QAI, mec.QIA, mec.kA, mec.kI, GAI, GIA)
    str += '\nASYMPTOTIC OPEN TIME DISTRIBUTION\n'
    str += 'term\ttau (ms)\tarea (%)\trate const (1/sec)\n'
    for i in range(mec.kA):
        str += ('{0:d}'.format(i+1) +
        '\t{0:.5g}'.format(-1.0 / roots[i] * 1000) +
        '\t{0:.5g}'.format(areas[i] * 100) +
        '\t{0:.5g}\n'.format(- roots[i]))
    areast0 = np.zeros(mec.kA)
    for i in range(mec.kA):
        areast0[i] = areas[i] * np.exp(- tres * roots[i])
    areast0 = areast0 / np.sum(areast0)
    str += ('Areas for asymptotic pdf renormalised for t=0 to\
    infinity (and sum=1), so areas can be compared with ideal pdf.\n')
    for i in range(mec.kA):
        str += ('{0:d}'.format(i+1) +
        '\t{0:.5g}\n'.format(areast0[i] * 100))
    mean = exact_mean_time(tres,
            mec.QAA, mec.QII, mec.QAI, mec.kA, mec.kI, GAI, GIA)
    str += ('Mean open time (ms) = {0:.5g}\n'.format(mean * 1000))

    # Exact pdf
    eigvals, gamma00, gamma10, gamma11 = exact_GAMAxx(mec, tres, open)
    str += ('\nEXACT OPEN TIME DISTRIBUTION\n')
    str += ('eigen\tg00(m)\tg10(m)\tg11(m)\n')
    for i in range(mec.k):
        str += ('{0:.5g}'.format(eigvals[i]) +
        '\t{0:.5g}'.format(gamma00[i]) +
        '\t{0:.5g}'.format(gamma10[i]) +
        '\t{0:.5g}\n'.format(gamma11[i]))

    str += ('\n\n*******************************************\n')
    # SHUT TIME DISTRIBUTIONS
    open = False
    # Ideal pdf
    eigs, w = ideal_dwell_time_pdf_components(mec.QII, qml.phiF(mec))
    str += ('IDEAL SHUT TIME DISTRIBUTION\n')
    str += pdfs.expPDF_printout(eigs, w)

    # Asymptotic pdf
    #roots = asymptotic_roots(mec, tres, open)
    roots = asymptotic_roots(tres,
        mec.QII, mec.QAA, mec.QIA, mec.QAI, mec.kI, mec.kA)
    #areas = asymptotic_areas(mec, tres, roots, open)
    areas = asymptotic_areas(tres, roots,
        mec.QII, mec.QAA, mec.QIA, mec.QAI, mec.kI, mec.kA, GIA, GAI)
    str += ('\nASYMPTOTIC SHUT TIME DISTRIBUTION\n')
    str += ('term\ttau (ms)\tarea (%)\trate const (1/sec)\n')
    for i in range(mec.kI):
        str += ('{0:d}'.format(i+1) +
        '\t{0:.5g}'.format(-1.0 / roots[i] * 1000) +
        '\t{0:.5g}'.format(areas[i] * 100) +
        '\t{0:.5g}\n'.format(- roots[i]))
    areast0 = np.zeros(mec.kI)
    for i in range(mec.kI):
        areast0[i] = areas[i] * np.exp(- tres * roots[i])
    areast0 = areast0 / np.sum(areast0)
    str += ('Areas for asymptotic pdf renormalised for t=0 to\
    infinity (and sum=1), so areas can be compared with ideal pdf.\n')
    for i in range(mec.kI):
        str += ('{0:d}'.format(i+1) +
        '\t{0:.5g}\n'.format(areast0[i] * 100))
    mean = exact_mean_time(tres,
            mec.QII, mec.QAA, mec.QIA, mec.kI, mec.kA, GIA, GAI)
    str += ('Mean shut time (ms) = {0:.6f}\n'.format(mean * 1000))

    # Exact pdf
    eigvals, gamma00, gamma10, gamma11 = exact_GAMAxx(mec, tres, open)
    str += ('\nEXACT SHUT TIME DISTRIBUTION\n' + 
        'eigen\tg00(m)\tg10(m)\tg11(m)\n')
    for i in range(mec.k):
        str += ('{0:.5g}'.format(eigvals[i]) +
        '\t{0:.5g}'.format(gamma00[i]) +
        '\t{0:.5g}'.format(gamma10[i]) +
        '\t{0:.5g}\n'.format(gamma11[i]))

    # Transition probabilities
    pi = transition_probability(mec.Q)
    str += ('\nProbability of transitions regardless of time:\n')
    for i in range(mec.k):
        str1 = '['
        for j in range(mec.k):
            str1 += '{0:.4g}\t'.format(pi[i,j])
        str1 += ']\n'
        str += str1

    # Transition frequency
    f = transition_frequency(mec.Q)
    str += ('\nFrequency of transitions (per second):\n')
    for i in range(mec.k):
        str1 = '['
        for j in range(mec.k):
            str1 += '{0:.4g}\t'.format(f[i,j])
        str1 += ']\n'
        str += str1
        
    return str
示例#15
0
def printout_occupancies(mec, tres):
    """
    """

    str = ('\n\n\n*******************************************\n\n' +
        'Open\tEquilibrium\tMean life\tMean latency (ms)\n' +
        'state\toccupancy\t(ms)\tto next shutting\n' +
        '\t\t\tgiven start in this state\n')

    pinf = qml.pinf(mec.Q)

    for i in range(mec.k):
        if i == 0:
            mean_life_A = ideal_subset_mean_life_time(mec.Q, 1, mec.kA)
            str += ('Subset A ' +
                '\t{0:.5g}'.format(np.sum(pinf[:mec.kA])) +
                '\t{0:.5g}\n'.format(mean_life_A * 1000))
        if i == mec.kA:
            mean_life_B = ideal_subset_mean_life_time(mec.Q, mec.kA + 1, mec.kE)
            str += ('\nShut\tEquilibrium\tMean life\tMean latency (ms)\n' +
                'state\toccupancy\t(ms)\tto next opening\n' +
                '\t\t\tgiven start in this state\n' +
                'Subset B ' +
                '\t{0:.5g}'.format(np.sum(pinf[mec.kA : mec.kE])) +
                '\t{0:.5g}\n'.format(mean_life_B * 1000))
        if i == mec.kE:
            mean_life_C = ideal_subset_mean_life_time(mec.Q, mec.kE + 1, mec.kG)
            str += ('\nSubset C ' +
                '\t{0:.5g}'.format(np.sum(pinf[mec.kE : mec.kG])) +
                '\t{0:.5g}\n'.format(mean_life_C * 1000))
        if i == mec.kG:
            mean_life_D = ideal_subset_mean_life_time(mec.Q, mec.kG + 1, mec.k)
            str += ('\nSubset D ' +
                '\t{0:.5g}'.format(np.sum(pinf[mec.kG : mec.k])) +
                '\t{0:.5g}\n'.format(mean_life_D * 1000))

        mean = ideal_mean_latency_given_start_state(mec, i+1)
        str += ('{0:d}'.format(i+1) +
            '\t{0:.5g}'.format(pinf[i]) +
            '\t{0:.5g}'.format(-1 / mec.Q[i,i] * 1000) +
            '\t{0:.5g}\n'.format(mean * 1000))

    expQFF = qml.expQt(mec.QFF, tres)
    expQAA = qml.expQt(mec.QAA, tres)
    GAF, GFA = qml.iGs(mec.Q, mec.kA, mec.kF)
    eGAF = qml.eGs(GAF, GFA, mec.kA, mec.kF, expQFF)
    eGFA = qml.eGs(GFA, GAF, mec.kF, mec.kA, expQAA)
    phiA = qml.phiHJC(eGAF, eGFA, mec.kA)
    phiF = qml.phiHJC(eGFA, eGAF, mec.kF)

    str += ('\n\nInitial vector for HJC openings phiOp =\n')
    for i in range(phiA.shape[0]):
        str += ('\t{0:.5g}'.format(phiA[i]))
    str += ('\nInitial vector for ideal openings phiOp =\n')
    phiAi = qml.phiA(mec)
    for i in range(phiA.shape[0]):
        str += ('\t{0:.5g}'.format(phiAi[i]))
    str += ('\nInitial vector for HJC shuttings phiSh =\n')
    for i in range(phiF.shape[0]):
        str += ('\t{0:.5g}'.format(phiF[i]))
    str += ('\nInitial vector for ideal shuttings phiSh =\n')
    phiFi = qml.phiF(mec)
    for i in range(phiF.shape[0]):
        str += ('\t{0:.5g}'.format(phiFi[i]))
    str += '\n'
    
    return str