liveBook · Manning

Simulation

As explained in Experimentation for Engineers

A computational representation of a system that estimates its business metrics offline by combining data, models, scientific models, or heuristics.

Simulation estimates a system’s business metrics offline by combining logged data with user or market models, scientific models, or heuristics. Unlike simple fitting metrics such as cross-entropy or R2, it represents the system’s components and produces outcomes such as revenue, engagement, profit, or CPU time. section 1.3.3

Use simulation as a fast, inexpensive supplement to experimentation. It can process months or years of data in minutes or hours and rerun many strategy variants, but its results depend on modeled behavior and may be biased by missing counterfactuals. Experiments remain the more accurate measurement of business impact. section 1.3 section 1.3.3

A practical simulation workflow:

  • Feed historical or production-log data into the same strategy or system logic used in production. section 1.3.3 section 6.1.1
  • Model or approximate the environment’s response when the system takes an action. section 1.3.3
  • Return a business or operational metric, then compare variants offline before selecting candidates for production evaluation. section 1.3.3 section 1.4

Trading and compiler simulations

A trading simulator replays historical trades and quotes through production strategy code, mimics market behavior, and estimates profit, risk, and shares traded. A compiler simulator configures JIT parameters, compiles a web server, replays production requests, and returns average CPU time with simulated measurement noise. section 1.3.3 section 6.1.1

Listing 6.1 JIT CPU time simulator
def jit_plus_server(parameters):
    x = np.array(parameters)                                     #1
    d = len(x)
    x1 = x - 0.15*np.ones(shape=(d,))                            #2
    x2 = x - 0.85*np.ones(shape=(d,))                            #2
    cpu_time = 2 - np.exp(-10*x1**2) - 0.5*np.exp(-10*x2**2)     #2
    return cpu_time.mean() + .005*np.random.normal()             #3

Inspect a compact Python simulator that maps JIT parameters to CPU time and adds random variation, making the system suitable for black-box optimization. section 6.1.1

How Experimentation for Engineers covers it

How deep it goes
Explains components, data flow, reruns, speed, and bias, then demonstrates parameterized Python and production-log simulations.
Examples
Uses trading-strategy replay, market-response modeling, JIT CPU-time measurement, production-request logs, and repeated parameter variants.
What you can do after
Evaluate offline metric estimates, compare many variants quickly, and choose candidates for production experiments while accounting for bias.
How it connects
Connects simulation to experimentation, offline model quality, domain knowledge, Bayesian optimization, and black-box optimization.

Also explained in

Compare how 6 books explain simulation →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Experimentation for Engineers. The section links point to the parts of the book it draws on.