Package stallone.api.ints

Examples of stallone.api.ints.IIntList


    /* (non-Javadoc)
     * @see stallone.mc.IMarkovChain#randomTrajectoryToState(int[])
     */
    public IIntArray randomTrajectoryToState(int[] endStates)
    {
        IIntList res = Ints.create.list(0);
        int c = startingState();
        res.append(c);

        int i = 0;
        while (!PrimitiveIntTools.contains(endStates, c))
        {
            c = dd.sample(c);

            if (i % nskip == 0)
            {
                res.append(c);
            }
            i++;
        }

        return (res);
View Full Code Here


    @Override
    public void perform()
    {
        int nfound = 0;
        int nsought = nClusters;
        IIntList acceptedCenterIndexes = intsNew.list(0);
        IDataList acceptedCenters = dataNew.list();

        int nAttempts = 0;
        while (nfound < nClusters && nAttempts <= 10)
        {
            // decide which indexes should be centers
            IIntArray I = intsNew.arrayRandomIndexes(datasize, nsought);
            ints.sort(I);
            // get corresponding data points
            IDataList datapoints = select(I);

            // add new ones
            for (int i=0; i<I.size(); i++)
            {
                if (isNew(acceptedCenters, datapoints.get(i)))
                {
                    acceptedCenterIndexes.append(I.get(i));
                    acceptedCenters.add(datapoints.get(i));
                }
            }

            nfound = acceptedCenters.size();
View Full Code Here

            IDoubleArray hmmChi = pmm.getOutputParameters();
            io.writeString(cmd.outdir+"/hmmChi.dat", doubles.toString(hmmChi,"\t","\n"));
        }
        else if (cmd.hmmTimescalesEstimate)
        {
            IIntList lagtimes = intsNew.list(0);
            lagtimes.append(cmd.taumin);
            for (double tau = cmd.taumin; tau <= cmd.taumax; tau *= cmd.taumult)
            {
                int lag = (int)tau;
                if (lag != lagtimes.get(lagtimes.size()-1))
                    lagtimes.append(lag);
            }

            PrintStream itsout = new PrintStream(cmd.outdir+"/hmm-its.dat");
           
            IDoubleArray lastTC = cmd.init_T;
            IDoubleArray lastChi = cmd.init_Chi;
           
            for (int i=0; i<lagtimes.size(); i++)
            {
                //set lag and timeshift
                int lag = lagtimes.get(i);
                System.out.println("\ntau = "+lag+"\n");

                // in direct mode, erase the results from last lag. Otherwise use as initialization.
                if (cmd.direct)
                {
View Full Code Here

    }
   
    private void merge(List<Leaf> leavesToMerge)
    {       
        // Create a merged leaf
        IIntList mergedIndexes = intsNew.list(0);
        for (Leaf l : leavesToMerge)
        {
            mergedIndexes.appendAll(l.indexes);
        }
        Leaf newLeaf = new Leaf(mergedIndexes);

        // remove old leaves and add new leaf
        leavesNew.removeAll(leavesToMerge);
View Full Code Here

                    }
                A.set(target.get(i), target.get(i), 1);
            }

        // identify 0-columns
        IIntList zeros = Ints.create.list(0);
        for (int j=0; j<A.columns(); j++)
            {
                boolean colzero = true;
                for (int i=0; i<A.rows(); i++)
                    if (A.get(i,j) != 0)
                        colzero = false;
                if (colzero)
                    zeros.append(j);
            }

        for (int j=0; j<A.columns(); j++)
            {
                if (!Ints.util.contains(target, j) && A.get(j,j) == 0)
                    zeros.append(j);
            }

        IIntArray nonzeros = Ints.util.removeValueToNew(Ints.create.listRange(0, A.rows()), zeros);

        // clean matrix
View Full Code Here

        return mix;
    }

    private IIntArray statesWithOverlap(IDoubleArray mix, double requestedQuality)
    {
        IIntList res = intsNew.list(0);

        for (int i = 0; i < mix.rows(); i++)
        {
            IDoubleArray pfrom = mix.viewRow(i);
            if (doubles.max(pfrom) < requestedQuality)
            {
                res.append(i);
            }
        }

        return res;
    }
View Full Code Here

    }

    private IIntArray selectStatesToSplit(IDoubleArray errors, double etot)
    {
        // select bad states.
        IIntList splitStates = intsNew.list(0);
       
        // error level reached? then return empty list
        if (etot <= requestedError)
            return splitStates;
View Full Code Here

        // sort
        Doubles.util.sort(uncleaned);

        // retrieve non-doubles
        IIntList Iclean = Ints.create.list(uncleaned.size());
        Iclean.set(0, 0);
        for (int i = 1; i < uncleaned.size(); i++)
        {
            if (uncleaned.get(i) != uncleaned.get(i - 1))
            {
                Iclean.append(i);
            }
        }

        return (subToNew(uncleaned, Iclean));
    }
View Full Code Here

        return (subToNew(arr, smallValueIndexes(arr, maxValue)));
    }

    public IIntArray smallValueIndexes(IDoubleArray arr, double maxValue)
    {
        IIntList res = Ints.create.list(0);
        for (int i = 0; i < arr.size(); i++)
        {
            if (arr.get(i) <= maxValue)
            {
                res.append(i);
            }
        }
        return (res);
    }
View Full Code Here

        return (subToNew(arr, largeValueIndexes(arr, minValue)));
    }

    public IIntArray largeValueIndexes(IDoubleArray arr, double minValue)
    {
        IIntList res = Ints.create.list(0);
        for (int i = 0; i < arr.size(); i++)
        {
            if (arr.get(i) >= minValue)
            {
                res.append(i);
            }
        }
        return (res);
    }
View Full Code Here

TOP

Related Classes of stallone.api.ints.IIntList

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.