diff --git a/prism/src/prism/PrismUtils.java b/prism/src/prism/PrismUtils.java
index 19e20e0f..abbc5a9b 100644
--- a/prism/src/prism/PrismUtils.java
+++ b/prism/src/prism/PrismUtils.java
@@ -393,7 +393,31 @@ public class PrismUtils
}
/**
- * Format a large integer, represented by a double, as a string.
+ * Normalise the given entries in the vector in-place such that that they sum to 1,
+ * I.e., for all indizes of entries, set
+ * {@code vector[s] = vector[s] / sum}, where
+ * {@code sum = sum_{s in entries} (vector[s])
+ * If {@code sum = 0.0}, all entries are set to {@code NaN}.
+ * @param vector the vector
+ * @param entries Iterable over the entries (must not contain duplicates)
+ * @return the altered vector
+ */
+ public static double[] normalise(double[] vector, IterableInt entries)
+ {
+ double sum = 0.0;
+ for (PrimitiveIterator.OfInt iter = entries.iterator(); iter.hasNext();) {
+ int state = iter.nextInt();
+ sum += vector[state];
+ }
+ for (PrimitiveIterator.OfInt iter = entries.iterator(); iter.hasNext();) {
+ int state = iter.nextInt();
+ vector[state] /= sum;
+ }
+ return vector;
+ }
+
+ /**
+ * Format a large integer, represented by a double, as a string. Un
*/
public static String bigIntToString(double d)
{