Package stallone.api.ints

Examples of stallone.api.ints.IIntArray


    }

    @Override
    public IDoubleArray next()
    {
        IIntArray c = count.get();

        for (int i=0; i<dim; i++)
            prePoint.set(i, pointPositions[i].get(c.get(i)));

        overflow = count.inc();

        return(prePoint);
    }
View Full Code Here


        if (etot <= requestedError)
            return splitStates;

        // else select the worst fraction
        int nselect = Math.max(1, (int)Math.sqrt(errors.size()));       
        IIntArray sortedIndexes = doubles.sortedIndexes(errors);
        return (ints.subToNew(sortedIndexes, sortedIndexes.size()-nselect, sortedIndexes.size()));
    }
View Full Code Here

   
    private void estimate()
            throws ParameterEstimationException
    {
            //  get discrete trajectory     
            IIntArray dtraj = mc.getCurrentDiscreteTrajectory();
            List<IIntArray> dtrajs = new ArrayList();
            dtrajs.add(dtraj);
           
            // construct estimator
        ninja = new NinjaEstimator(dtrajs);
View Full Code Here

     * @return
     */
    private boolean split()
    {
            // select bad states.
            IIntArray badStates = selectStatesToSplit(errors, etot);

            //IDoubleArray mix = cmd.getStateMixing(chiopt, pi, piCopt);
            //IIntArray badStates = cmd.statesWithOverlap(mix, cmd.requestedStateQuality);

            //System.out.println("piObs: "+pi);
            //System.out.println("piHidden: "+piCopt);
            //System.out.println("mixing:\n"+mix);
            //System.out.println();

            //cmd.printStateQualities(mix, pi);
            //System.out.println();

            if (badStates.size() == 0)
            {
                System.out.println("No overlapping states left. DONE!");
                return false;
            }
            else
View Full Code Here

        IIntList goodStates = intsNew.list(0);
        int nselect = errors.size()/2;  
        IIntArray sortedIndexes = doubles.sortedIndexes(errors);
        IIntArray mergeCandidates = ints.subToNew(sortedIndexes, 0, nselect);
        */
        IIntArray mergeCandidates = intsNew.arrayRange(hmmChi.rows());
       
        // compute coming-from-probabilities
        /*
        IDoubleArray pComeFrom = hmmChi.copy();
        for (int i=0; i<pComeFrom.rows(); i++)
            for (int I=0; I<pComeFrom.columns(); I++)
                pComeFrom.set(i,I, hmmChi.get(i,I) * hmmpiC.get(I) / msmpi.get(i));
                */
        IDoubleArray pComeFrom = hmmChi.copy();
        alg.normalizeRows(pComeFrom, 1);

           
        System.out.println(" COME-FROM array:");
        doubles.print(pComeFrom,"\t","\n");
       
        // select optimal groups
        ArrayList<IIntArray> groups = new ArrayList();
        for (int i=0; i<nhidden; i++)
            groups.add(intsNew.list(0));
       
        for (int i=0; i<mergeCandidates.size(); i++)
        {
            int s = mergeCandidates.get(i);
            int g = doubleArrays.maxIndex(pComeFrom.getRow(s));
            if (pComeFrom.get(i,g) > 0.99)
                ((IIntList)groups.get(g)).append(s);
        }

        // remove empty groups
        for (int i=groups.size()-1; i>=0; i--)
        {
            if (groups.get(i).size() <= 1)
            {
                System.out.println("removing merge group "+i+" with size "+groups.get(i).size());
                groups.remove(i);
            }
            else
            {
                // output
                for (int j=0; j<groups.size(); j++)
                {
                    IIntArray group = groups.get(j);
                    System.out.println("- merge group "+j+": "+ints.toString(group,"",","));
                    IDoubleArray groupChi = pComeFrom.view(group.getArray(), intsNew.arrayRange(0, nhidden).getArray());
                    doubles.print(groupChi,"\t","\n");
                    System.out.println();
                }       
            }       
        }
View Full Code Here

    }
   
    private ArrayList<IIntArray> mergeGroupsBySimilarity()
    {
        double maxdist = 0.01;
        IIntArray mergeCandidates = intsNew.arrayRange(hmmChi.rows());
       
        // compute coming-from-probabilities
        IDoubleArray pComeFrom = hmmChi.copy();
        alg.normalizeRows(pComeFrom, 1);
           
        System.out.println(" COME-FROM array:");
        doubles.print(pComeFrom,"\t","\n");
       
        ArrayList<IIntList> groups = new ArrayList();
        groups.add(intsNew.listFrom(mergeCandidates.get(0)));
       
        for (int i=1; i<mergeCandidates.size(); i++)
        {
            int s = mergeCandidates.get(i);
            IDoubleArray scf = pComeFrom.viewRow(s);
           
            double[] distances = new double[groups.size()];
            for (int j=0; j<distances.length; j++)
            {
                IDoubleArray ocf = pComeFrom.viewRow(groups.get(j).get(0));                               
                distances[j] = alg.norm(alg.subtract(scf, ocf));
               
                System.out.println(i+" "+j+":");
                System.out.println(scf);
                System.out.println(ocf);
                System.out.println(distances[j]);
               
            }

            // test if s is very similar to an existing merge group
            if(doubleArrays.min(distances) < maxdist)
            {
                groups.get(doubleArrays.minIndex(distances)).append(s);
            }
            else // new group
            {
                groups.add(intsNew.listFrom(s));
            }
        }
       
        // remove empty groups
        for (int i=groups.size()-1; i>=0; i--)
        {
            if (groups.get(i).size() <= 1)
            {
                System.out.println("removing merge group "+i+" with size "+groups.get(i).size());
                groups.remove(i);
            }
            else
            {
                // output
                for (int j=0; j<groups.size(); j++)
                {
                    IIntArray group = groups.get(j);
                    System.out.println("- merge group "+j+": "+ints.toString(group,"",","));
                    IDoubleArray groupChi = pComeFrom.view(group.getArray(), intsNew.arrayRange(0, nhidden).getArray());
                    doubles.print(groupChi,"\t","\n");
                    System.out.println();
                }       
            }       
        }
View Full Code Here

        }


        // OUTPUT
        // write discrete trajectory
        IIntArray dtrajFinal = cmd.mc.getCurrentDiscreteTrajectory();
        intseq.writeIntSequence(dtrajFinal, cmd.outdir + "/dtraj.dat");
        //
        // write cluster centers
        /*ArrayList<IDoubleArray> centers = cmd.mc.getLeafCenters();
        String centersOutFile = cmd.outdir + "/centers." + io.getExtension(cmd.inputFiles.get(0));
View Full Code Here

    /**
    @return the indexes of the n smalles values in arr.
     */
    public IIntArray smallestIndexes(IDoubleArray arr, int n)
    {
        IIntArray indexes = sortedIndexes(arr);
        return (Ints.util.subToNew(indexes, 0, n));
    }
View Full Code Here

    /**
    @return the indexes of the n smalles values in arr.
     */
    public IIntArray largestIndexes(IDoubleArray arr, int n)
    {
        IIntArray indexes = sortedIndexes(arr);
        IIntArray largest = Ints.util.subToNew(indexes, indexes.size() - n, indexes.size());
        Ints.util.mirror(largest);
        return (largest);
    }
View Full Code Here

    {
        if (arr.size() == 0)
        {
            return (arr);
        }
        IIntArray keep = Ints.create.arrayRange(arr.size());
        keep = Ints.util.removeValueToNew(keep, index);
        return (subToNew(arr, keep));
    }
View Full Code Here

TOP

Related Classes of stallone.api.ints.IIntArray

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.