You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

graph-simulator

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

graph-simulator

A tool to simulate from graphs

0.2.9
pipPyPI
Maintainers
1

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

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts