Package stallone.api.doubles

Examples of stallone.api.doubles.IDoubleArray


        {
            int nconv = cmd.nHMMConv[i];
            cmd.ninja.setNIterHMMMax(nconv);
            cmd.ninja.estimate();

            IDoubleArray hmmTimescales = cmd.ninja.getHMMTimescales();
            double[] hmmLikelihoodHistory = cmd.ninja.getHMMLikelihoodHistory();
            double lastLikelihood = hmmLikelihoodHistory[hmmLikelihoodHistory.length-1];
           
            out.println(nconv+"\t"+lastLikelihood+"\t"+doubles.toString(hmmTimescales));
        }
View Full Code Here


            System.out.println(getUsageString());
            System.exit(0);
        }
       
        // read lag times
        IDoubleArray lagFile = doublesNew.fromFile(cmd.inDir+"/hmm-its.dat");
        int[] lagtimes = intArrays.from(lagFile.getColumn(0));

        // read matrices and Chi
        for (int tau: lagtimes)
        {
            IDoubleArray TC = doublesNew.fromFile(cmd.inDir+"/hmm-TC-lag"+tau+".dat");           
            IDoubleArray Pi = doublesNew.diag(msm.stationaryDistribution(TC));
            IDoubleArray Chi = doublesNew.fromFile(cmd.inDir+"/hmm-Chi-lag"+tau+".dat");           

            // diagonalize TC
            IEigenvalueDecomposition evd = alg.evd(TC);
            IDoubleArray R = evd.R().viewReal();
            IDoubleArray L = alg.inverse(R);

            // pi
            IDoubleArray Lbig = alg.product(L, alg.transposeToNew(Chi));
            IDoubleArray pibig = Lbig.viewRow(0);
            alg.normalize(pibig, 1);
            IDoubleArray PibigInv = doublesNew.diag(pibig.size(), 1);
            for (int i=0; i<pibig.size(); i++)
                PibigInv.set(i,i,1.0/pibig.get(i));
           
            // Rbig
            IDoubleArray Rbig = alg.product(alg.product(PibigInv, Chi), alg.product(Pi, R));
           

            // output
            io.writeString(cmd.outDir+"/hmm-pibig-lag"+tau+".dat", doubles.toString(pibig,"\n","\n"));
            io.writeString(cmd.outDir+"/hmm-Rbig-lag"+tau+".dat", doubles.toString(Rbig,"\t","\n"));
View Full Code Here

    }

    @Override
    public IDoubleArray next()
    {
        IDoubleArray res = null;
        try
        {
            res = loader.get(itraj, iindex);
            advance();
        } catch (IOException e)
View Full Code Here

        }

        @Override
        public IDoubleArray next()
        {
            IDoubleArray res = get(i);
            i++;
            return res;
        }
View Full Code Here

        }

        @Override
        public IDoubleArray next()
        {
            IDoubleArray res = get(i);
            i++;
            return res;
        }
View Full Code Here

    }

    @Override
    public IDoubleArray next()
    {
        IDoubleArray res = seq.get(i);
        i++;
        return res;
    }
View Full Code Here

            System.exit(0);
        }

        Arguments arg = new Arguments(args);

        IDoubleArray C = doublesNew.fromFile(arg.getArgument("iC"));
        List<IIntArray> components = graph.connectedComponents(C);
        int[] I = intArrays.sortedIndexes(intseq.lengths(components));

        System.out.println("Strong Components: "+I.length);
        System.out.println("Lengths: "+intArrays.toString(I,", "));
View Full Code Here

        }
        Arguments arg = new Arguments(args);

        if (arg.hasCommand("sparse2dense"))
        {
            IDoubleArray T = doublesNew.fromFile(arg.getArgument("sparse2dense"));
            doubles.writeMatrixDense(T, System.out);
        }
        if (arg.hasCommand("dense2sparse"))
        {
            IDoubleArray T = doublesNew.fromFile(arg.getArgument("dense2sparse"));
            doubles.writeMatrixSparse(T, System.out);
        }
        if (arg.hasCommand("eigenvalues"))
        {
            IDoubleArray T = doublesNew.fromFile(arg.getArgument("eigenvalues"));
            IEigenvalueDecomposition evd = alg.evd(T);

            if (arg.hasCommand("norm"))
            {
                doubles.print(evd.getEvalNorm(), "\n");
            }
            else if (arg.hasCommand("complex"))
            {
                IComplexArray eval = evd.getEval();
                for (int i=0; i<eval.size(); i++)
                    System.out.println(eval.getRe(i)+" + "+eval.getIm(i)+"i");
            }
            else
            {
                doubles.print(evd.getEvalRe(), "\n");
            }
        }
        if (arg.hasCommand("eigenvectors"))
        {
            IDoubleArray T = doublesNew.fromFile(arg.getArgument("eigenvectors"));
            if (arg.hasCommand("left"))
                alg.transpose(T);
            int n = arg.getIntArgument("eigenvectors", 1);

            IDoubleArray EV = alg.evd(T).R();
            EV = EV.viewBlock(0, EV.rows(), 0, n);
            doubles.print(EV, " ", "\n");
        }

    }
View Full Code Here

     * @param prior
     * @return
     */
    public IDoubleArray createPosteriorCountsNeighbor(IDoubleArray observedCounts, double prior)
    {
        IDoubleArray Cprior = observedCounts.create(observedCounts.rows(), observedCounts.columns());
        for (IDoubleIterator it = observedCounts.nonzeroIterator(); it.hasNext(); it.advance())
        {
            int row = it.row();
            int col = it.column();
            if (observedCounts.get(row,col)+observedCounts.get(col,row) > 0)
            {
                Cprior.set(row,col,prior);
                Cprior.set(col,row,prior);
            }
        }
        return(new PosteriorCountMatrix(Cprior, observedCounts));
    }
View Full Code Here

    public PCCA createPCCA(IDoubleArray M, int nstates)
    {
        PCCA pcca = new PCCA();

        IDoubleArray evec = M;

        if (MarkovModel.util.isTransitionMatrix(M))
        {
            IEigenvalueDecomposition evd = Algebra.util.evd(M,nstates);
            evec = evd.getRightEigenvectorMatrix();
            evec = evec.viewBlock(0,0,M.rows(),nstates);
        }
        else
        {
            if (evec.columns() < nstates)
                throw(new IllegalArgumentException("Attempting to create PCCA decomposition into "+nstates+" states."+
                                                    "but only "+evec.columns()+" eigenvectors were provided"));
        }

        pcca.setEigenvectors(evec);
        pcca.perform();
View Full Code Here

TOP

Related Classes of stallone.api.doubles.IDoubleArray

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.