Package stallone.api.doubles

Examples of stallone.api.doubles.IDoubleArray


    private IDataList select(IIntArray indexes)
    {
        IDataList res = dataNew.list();
        Iterator<IDoubleArray> dataIterator = data.iterator();
        IDoubleArray x;
        int k = 0;
        for (int i=0; i<datasize; i++)
        {
            if (! dataIterator.hasNext())
                throw(new RuntimeException("Data set is shorter than specified"));
View Full Code Here


     * @param data
     * @return the autocorrelations of the data on the tau grid specified
     */
    public IDoubleArray correlate(IDoubleArray time, IDoubleArray data)
    {
        IDoubleArray res = doublesNew.array(lagtimes.size());

        for (int i = 0; i < res.size(); i++)
        {
            res.set(i, correlate(time, data, lagtimes.get(i), averageWidths.get(i)));
        }

        return res;
    }
View Full Code Here

     * @param time
     * @param data
     */
    public void add(IDoubleArray time, IDoubleArray data)
    {
        IDoubleArray c = correlate(time, data);
        for (int i = 0; i < c.size(); i++)
        {
            if (!Double.isNaN(c.get(i)))
            {
                correlation.set(i, correlation.get(i) + data.size() * c.get(i));
                weights.set(i, weights.get(i) + data.size());
            }
        }

        sum += doubles.sum(data);
View Full Code Here

    {
    }

    private void initX()
    {
        IDoubleArray CCT = Algebra.util.add(C, Algebra.util.transposeToNew(C));
        this.X = Doubles.create.symmetric(CCT);

        Algebra.util.scale(1.0 / Algebra.util.sum(this.X), this.X);

        this.itX = this.X.nonzeroIterator();
View Full Code Here

        sumOfWeights += time.size();
    }

    public IDoubleArray getCorrelation()
    {
        IDoubleArray res = doublesNew.array(correlation.size());
        for (int i=0; i<res.size(); i++)
            res.set(i, correlation.get(i)/weights.get(i));
        return res;
    }
View Full Code Here

    {
        // output likelihood list
        //for (int i=0; i<this.logliks.size(); i++)
        //    System.out.println("# "+i+"\t"+this.logliks.get(i));

        IDoubleArray T = X.create(X.rows(), X.columns());
        for (IDoubleIterator it = X.nonzeroIterator(); it.hasNext(); it.advance())
        {
            int i = it.row();
            int j = it.column();
            T.set(i, j, X.get(i,j) / Xrow[i]);
            //System.out.println(i+","+j+"\t"+X.get(i,j)+"\t"+Xrow[i]+"\t"+T.get(i,j));
            //if (i != j)
            //{
            //    T.set(j, i, X.get(j,i) / Xrow[j]);
            //}
View Full Code Here

        return res;
    }

    public IDoubleArray getCorrelationMeanFree()
    {
        IDoubleArray res = doublesNew.array(correlation.size());
        double shift =(sum/sumOfWeights)*(sum/sumOfWeights);
        for (int i=0; i<res.size(); i++)
            res.set(i, (correlation.get(i)/weights.get(i)) - shift);
        return res;
    }
View Full Code Here

public class ArrayDifference //implements IMatrixSum
{

    public IDoubleArray subtractToNewDense(final IDoubleArray a, final IDoubleArray b)
    {
        IDoubleArray target = a.copy();
        subtractDense(a, b, target);
        return target;
    }
View Full Code Here

        return target;
    }

    public IDoubleArray subtractToNewSparse(final IDoubleArray a, final IDoubleArray b)
    {
        IDoubleArray target = a.copy();
        subtractSparse(a, b, target);
        return target;
    }
View Full Code Here

        while (lagtimes.get(lagtimes.size() - 1) < maxtime)
        {
            lagtimes.append((lagtimes.get(lagtimes.size() - 1) + 1) * 1.1);
        }
        //IDoubleArray lagtimes = doublesNew.arrayFrom(1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000, 500000, 1000000);
        IDoubleArray averageWidths = doublesNew.array(lagtimes.size());
        for (int i = 0; i < averageWidths.size(); i++)
        {
            averageWidths.set(i, Math.max(1.0, 0.1 * lagtimes.get(i)));
        }
        EventCorrelator correlator = new EventCorrelator(lagtimes, averageWidths);


        for (int i = 0; i < inputFiles.size(); i++)
        {
            IDoubleArray time = data.readColumn(inputFiles.get(i), timecol);
            IDoubleArray don = data.readColumn(inputFiles.get(i), col1);
            IDoubleArray acc = data.readColumn(inputFiles.get(i), col2);
            IDoubleArray E = doublesNew.array(don.size());
            for (int j = 0; j < E.size(); j++)
            {
                E.set(j, acc.get(j) / (don.get(j) + acc.get(j)));
            }

            correlator.add(time, E);
        }

        IDoubleArray corr = null;
        if (subtractMean)
            corr=correlator.getCorrelationMeanFree();
        else
            corr=correlator.getCorrelation();


        //IDoubleArray corr = correlator.correlate(time, E);

        for (int i = 0; i < lagtimes.size(); i++)
        {
            System.out.println(lagtimes.get(i) + "\t" + corr.get(i));
        }
    }
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.