Skip to content
Julie edited this page Jun 13, 2019 · 6 revisions

Sample N weights summing up to 1

The Python script can be used as follows to create M sets each containing N random values that sum up to 1.0:

# some code

The matrix contains M=3 sets each containing N=5 values:

# the resulting three sets

They all sum up to 1.0:

# showing that sum is 1.0 for all three sets

Sample N weights providing (N-1) uniformly sampled random numbers

For most applications such as Sensitivity Analysis, however, the method is providing the user with random numbers distributed between 0 and 1 that need to be used to perform the analysis.

Hence, the algorithm allows you to provide a matrix of random numbers rr (M rows and N-1 columns) that will be transformed into N weights that will sum up to 1.0.

# some code

The matrix contains M=3 sets each containing N=5 values:

# the resulting three sets

Funded under IMPC project of Global Water Futures program.

Table of contents

Clone this wiki locally