{ } Raw JSON

bundles / scipy latest / scipy / stats / _sobol / _initialize_direction_numbers

cython_function_or_method

scipy.stats._sobol:_initialize_direction_numbers

Signature

def   _initialize_direction_numbers ( poly vinit dtype )

Summary

Load direction numbers into two arrays.

Parameters

poly, vinit : np.ndarray

Direction numbers arrays to fill.

dtype : {np.uint32, np.uint64}

Which dtype to use.

Notes

Direction numbers obtained using the search criterion D(6) up to the dimension 21201. This is the recommended choice by the authors.

Original data can be found at https://web.maths.unsw.edu.au/~fkuo/sobol/. For additional details on the quantities involved, see [1].

[1] S. Joe and F. Y. Kuo. Remark on algorithm 659: Implementing sobol's

quasirandom sequence generator. ACM Trans. Math. Softw., 29(1):49-57, Mar. 2003.

The C-code generated from putting the numbers in as literals is obscenely large/inefficient. The data file was thus packaged and save as an .npz data file for fast loading using the following code (this assumes that the file https://web.maths.unsw.edu.au/~fkuo/sobol/new-joe-kuo-6.21201 is present in the working directory):

import pandas as pd import numpy as np

# read in file content with open("./new-joe-kuo-6.21201", "r") as f: lines = f.readlines()

rows = []

# parse data from file line by line for l in lines[1:]: nums = [int(n) for n in l.replace("

", "").split()]

d, s, a = nums[:3] vs = {f"v{i}": int(v) for i,v in enumerate(nums[3:])} rows.append({"d": d, "s": s, "a": a, **vs})

# read in as dataframe, explicitly use zero values df = pd.DataFrame(rows).fillna(0).astype(int)

# perform conversion df["poly"] = 2 * df["a"] + 2 ** df["s"] + 1

# ensure columns are properly ordered vs = df[[f"v{i}" for i in range(18)]].values

# add the degenerate d=1 column (not included in the data file) vs = np.vstack([vs[0][np.newaxis, :], vs]) poly = np.concatenate([[1], df["poly"].values])

# save as compressed .npz file to minimize size of distribution np.savez_compressed("./_sobol_direction_numbers", vinit=vs, poly=poly)

Aliases

  • scipy.stats._sobol._initialize_direction_numbers