Skip to content

Commit

Permalink
fix bug with scaling samples in Morris OAT method
Browse files Browse the repository at this point in the history
  • Loading branch information
jdherman committed Dec 29, 2014
1 parent 0c8dd84 commit c1de4e4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
8 changes: 5 additions & 3 deletions SALib/sample/morris_oat.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,23 @@ def sample(N, param_file, num_levels, grid_jump):
(np.mat(B) * np.mat(P) * np.mat(DM) + 1) * \
np.mat(delta_diag) + np.mat(x_base)

#scale_samples(X, pf['bounds'])
return X

if __name__ == "__main__":

parser = common_args.create()
parser.add_argument('--num-levels', type=int, required=False,
parser.add_argument('-l', type=int, required=False,
default=10, help='Number of grid levels (Morris only)')
parser.add_argument('--grid-jump', type=int, required=False,
default=5, help='Grid jump size (Morris only)')
args = parser.parse_args()

pf = read_param_file(args.paramfile)
np.random.seed(args.seed)
rd.seed(args.seed)
param_values = sample(args.samples, args.paramfile,
num_levels=args.num_levels, grid_jump=args.grid_jump)
num_levels=args.l, grid_jump=args.grid_jump)
scale_samples(param_values, pf['bounds'])

np.savetxt(args.output, param_values, delimiter=args.delimiter,
fmt='%.' + str(args.precision) + 'e')
6 changes: 3 additions & 3 deletions examples/morris/morris.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# Example: generating samples from the command line
cd ../../ # hack
python -m SALib.sample.morris \
python -m SALib.sample.morris_oat \
-n 100 \
-p ./SALib/test_functions/params/Ishigami.txt \
-o model_input.txt \
Expand Down Expand Up @@ -45,8 +45,8 @@ python -m SALib.analyze.morris \
-Y model_output.txt \
-c 0 \
-X model_input.txt \
-r 1000
-l 10 \
-r 1000 \
-l=10 \
--grid-jump=5

# Options:
Expand Down

0 comments on commit c1de4e4

Please sign in to comment.