Skip to main content

A tool to simulate from graphs

Project description

graph_simulator

Fast library to simulate data from directed acyclic graphs (DAGs).

Dependencies between vertices in the graph are specified in a human-readable YAML file. For example, the simple graph \( X \rightarrow Y \) is specified by the YAML code below:

X:
  kernel:
    type: "uniform"
    sample_domain: [0, 1]
    terms: null
  dependencies: null

Y:
  kernel:
    type: "linear"
    sample_domain: [1, 1.5]
    noise: 0.1
    terms:
      - intercept: 1
        indicators: null
        value: 0.5
        variable:
          1: "X"
  dependencies:
    1: ["X"]

Here, X does not have any parents, as specified by dependencies: null, and it is uniformly distributed with support \( {0, 1} \). In contrast, \( Y_t \) has a parent \( X_{t-1} \) (graphically we write \( X_{t-1} \rightarrow Y_t \)), which is specified by 1: ["X"] under dependencies — interpreted as “X of lag 1”.

In the kernel section, we see that Y depends on its parents linearly (type: "linear"), but takes a random value with probability 0.1 in \( {1, 1.5} \), as indicated by noise: 0.1 and sample_domain: [1, 1.5].

The linear dependency is specified in the terms subsection. In this case, there is a single term composed of an intercept of value 1 (intercept: 1) plus a value of 0.5 (value: 0.5) times the value of “X at lag 1” (1: "X" under variable). Terms may, in addition, depend on indicator functions that can render the whole term zero.

Thus, in the above example, we may write the functional form of \( Y_t \) as:

Y_t =
\begin{cases}
  1 + 0.5 \cdot X_{t-1}, & \text{with probability } 0.9 \\\\
  \text{Unif}(\{1, 1.5\}), & \text{with probability } 0.1
\end{cases}

Supported kernels:

  • uniform
  • linear
  • poisson
  • binomial
  • mixed
  • constant

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

graph_simulator-0.2.9.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

graph_simulator-0.2.9-cp312-cp312-macosx_15_0_arm64.whl (107.8 kB view details)

Uploaded CPython 3.12macOS 15.0+ ARM64

File details

Details for the file graph_simulator-0.2.9.tar.gz.

File metadata

  • Download URL: graph_simulator-0.2.9.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.10

File hashes

Hashes for graph_simulator-0.2.9.tar.gz
Algorithm Hash digest
SHA256 ae0007632b5020a8a0683b4f43da0737296de75d4ae6f3f1b6702c49fe842d96
MD5 a864171dcf4b9ec3dc698b3634649522
BLAKE2b-256 7caf9b7e04cccb1ce1a632da371539c6e811468a664ac47a2f4604633a6c1582

See more details on using hashes here.

File details

Details for the file graph_simulator-0.2.9-cp312-cp312-macosx_15_0_arm64.whl.

File metadata

File hashes

Hashes for graph_simulator-0.2.9-cp312-cp312-macosx_15_0_arm64.whl
Algorithm Hash digest
SHA256 93a6f199b6d9f6ffefe82fcdf929f411cc7937374668878babb0fc33d91c6ec5
MD5 b5b489707d69ece046c02d64e38f66c0
BLAKE2b-256 b479d9f562b153fe4f818a2ca70f3a82fb29c7bda98b691ccd0b13bef07abcae

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page