Example usage for org.apache.commons.math.stat.regression SimpleRegression getSlopeStdErr

List of usage examples for org.apache.commons.math.stat.regression SimpleRegression getSlopeStdErr

Introduction

In this page you can find the example usage for org.apache.commons.math.stat.regression SimpleRegression getSlopeStdErr.

Prototype

public double getSlopeStdErr() 

Source Link

Document

Returns the <a href="http://www.xycoon.com/standerrorb(1).htm">standard error of the slope estimate</a>, usually denoted s(b1).

Usage

From source file:msc.fall2015.stock.kmeans.hbase.mapreduce.StockDataReaderMapper.java

public void map(ImmutableBytesWritable row, Result value, Context context)
        throws InterruptedException, IOException {
    SimpleRegression regression;
    for (Map.Entry<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> columnFamilyMap : value.getMap()
            .entrySet()) {//  w  w w.  ja v  a  2  s . c o m
        regression = new SimpleRegression();
        int count = 1;
        for (Map.Entry<byte[], NavigableMap<Long, byte[]>> entryVersion : columnFamilyMap.getValue()
                .entrySet()) {
            for (Map.Entry<Long, byte[]> entry : entryVersion.getValue().entrySet()) {
                String rowKey = Bytes.toString(value.getRow());
                String column = Bytes.toString(entryVersion.getKey());
                byte[] val = entry.getValue();
                String valOfColumn = new String(val);
                System.out.println(
                        "RowKey : " + rowKey + " Column Key : " + column + " Column Val : " + valOfColumn);
                if (!valOfColumn.isEmpty()) {
                    String[] priceAndCap = valOfColumn.split("_");
                    if (priceAndCap.length > 1) {
                        String pr = priceAndCap[0];
                        if (pr != null && !pr.equals("null")) {
                            double price = Double.valueOf(pr);
                            if (price < 0) {
                                price = price - 2 * price;
                            }
                            System.out.println("Price : " + price + " count : " + count);
                            regression.addData(count, price);
                        }
                    }
                }
            }
            count++;
        }
        // displays intercept of regression line
        System.out.println("Intercept : " + regression.getIntercept());

        // displays slope of regression line
        System.out.println("Slope : " + regression.getSlope());

        // displays slope standard error
        System.out.println("Slope STD Error : " + regression.getSlopeStdErr());
    }
}

From source file:edu.indiana.soic.ts.crunch.CrunchDataReader.java

public PTable<String, String> extractText(PTable<ImmutableBytesWritable, Result> tableContent) {
    return tableContent.parallelDo("Read data",
            new DoFn<Pair<ImmutableBytesWritable, Result>, Pair<String, String>>() {
                @Override//  ww w. j a va  2  s  .c o  m
                public void process(Pair<ImmutableBytesWritable, Result> row,
                        Emitter<Pair<String, String>> emitter) {
                    SimpleRegression regression;
                    NavigableMap<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> map = row.second()
                            .getMap();
                    System.out.println(map.size());
                    for (Map.Entry<byte[], NavigableMap<byte[], NavigableMap<Long, byte[]>>> columnFamilyMap : map
                            .entrySet()) {
                        regression = new SimpleRegression();
                        int count = 1;
                        for (Map.Entry<byte[], NavigableMap<Long, byte[]>> entryVersion : columnFamilyMap
                                .getValue().entrySet()) {
                            for (Map.Entry<Long, byte[]> entry : entryVersion.getValue().entrySet()) {
                                String rowKey = Bytes.toString(row.second().getRow());
                                String column = Bytes.toString(entryVersion.getKey());
                                byte[] val = entry.getValue();
                                String valOfColumn = new String(val);
                                System.out.println("RowKey : " + rowKey + " Column Key : " + column
                                        + " Column Val : " + valOfColumn);
                                if (!valOfColumn.isEmpty()) {
                                    String[] priceAndCap = valOfColumn.split("_");
                                    if (priceAndCap.length > 1) {
                                        String pr = priceAndCap[0];
                                        if (pr != null && !pr.equals("null")) {
                                            double price = Double.valueOf(pr);
                                            if (price < 0) {
                                                price = price - 2 * price;
                                            }
                                            System.out.println("Price : " + price + " count : " + count);
                                            regression.addData(count, price);
                                        }
                                    }
                                }
                            }
                            count++;
                        }
                        // displays intercept of regression line
                        System.out.println("Intercept : " + regression.getIntercept());

                        // displays slope of regression line
                        System.out.println("Slope : " + regression.getSlope());

                        // displays slope standard error
                        System.out.println("Slope STD Error : " + regression.getSlopeStdErr());
                        emitter.emit(new Pair<String, String>(String.valueOf(regression.getIntercept()),
                                String.valueOf(regression.getSlope())));
                    }
                }
            }, Writables.tableOf(Writables.strings(), Writables.strings()));
}