Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.*;

public class Main {
    /**
     * 
     * @param pressingLength length of pause between clicks
     * @return mathExpectation values list 
     */
    public static List<Double> mathExpectation(Map<String, Long> pressingLength) {
        List<Double> mathExpectation = new ArrayList<Double>();
        int N = pressingLength.size() - 1;
        //math Expectation
        double expectation = 0.0;

        for (String key : pressingLength.keySet()) {
            for (String k : pressingLength.keySet()) {
                if (!k.equals(key)) {
                    expectation += pressingLength.get(k);
                }
            }
            mathExpectation.add(expectation / N);
            expectation = 0.0;
        }
        return mathExpectation;
    }
}