/* (non-Javadoc) * @see playground.johannes.gsv.synPop.analysis.AnalyzerTask#analyze(java.util.Collection, java.util.Map) */ @Override public void analyze(Collection<PlainPerson> persons, Map<String, DescriptiveStatistics> results) { TDoubleArrayList ages = new TDoubleArrayList(); TDoubleArrayList incomes = new TDoubleArrayList(); for (PlainPerson person : persons) { String aStr = person.getAttribute(CommonKeys.PERSON_AGE); String iStr = person.getAttribute(CommonKeys.HH_INCOME); // String mStr = person.getAttribute(CommonKeys.HH_MEMBERS); // if(aStr != null && iStr != null && mStr != null) { if (aStr != null && iStr != null) { double age = Double.parseDouble(aStr); double income = Double.parseDouble(iStr); // double members = Double.parseDouble(mStr); ages.add(age); // incomes.add(income/members); incomes.add(income); } } try { // TDoubleDoubleHashMap hist = Histogram.createHistogram(ages.toNativeArray(), new // LinearDiscretizer(5), false); TDoubleDoubleHashMap hist = Histogram.createHistogram(ages.toNativeArray(), new DummyDiscretizer(), false); TXTWriter.writeMap(hist, "age", "n", getOutputDirectory() + "/age.txt"); hist = Histogram.createHistogram(incomes.toNativeArray(), new LinearDiscretizer(500), false); TXTWriter.writeMap(hist, "income", "n", getOutputDirectory() + "/income.txt"); TXTWriter.writeScatterPlot( ages, incomes, "age", "income", getOutputDirectory() + "/age.income.txt"); TXTWriter.writeMap( Correlations.mean(ages.toNativeArray(), incomes.toNativeArray()), "age", "income", getOutputDirectory() + "/age.income.mean.txt"); } catch (IOException e) { e.printStackTrace(); } }
@Override public void apply(Person person1) { PlainPerson person = (PlainPerson) person1; String str = person.getAttribute("homeCoord"); ActivityFacility fac; if (str != null) { Coord coord = string2Coord(str); fac = facilities.getClosest(coord, ActivityTypes.HOME); } else { fac = facilities.randomFacility(ActivityTypes.HOME); } person.setUserData(SwitchHomeLocation.USER_FACILITY_KEY, fac); }