Synthetic Data & Seeding Models
A Beginner's Guide to Creating Test Data
Learn how to generate realistic datasets, reproducibly
What is Synthetic Data?
Artificial data created by a program, not collected from reality
Why Use It?
- Development: Build & test before real data exists
- Testing: Create edge cases & stress scenarios
- Sharing: Use realistic data without privacy concerns
- Reproducibility: Same seed = same dataset every time
- Scale: Generate millions of records instantly
Real Example: Supply Chain
How Felementum generates realistic supply chain networks:
Structure
Tier 0 (OEM) → Tier 1-14 (Integrators → Mines)
Thousands of companies, millions of connections
Key Features
- Multiple tier levels with realistic pyramid structure
- Deterministic connections between tiers
- Real-world locations and material types
- Reproducible via seed (42 = same network every time)
Core Concept #1: Seed
A seed makes randomness predictable
function seededRandom(seed) {
return (seed * 16807) % 2147483647;
}
// Seed 42 always produces:
number1 = seededRandom(42); // 705,894,294
number2 = seededRandom(...); // 1,973,480,210
Why This Matters
You can say "Run test with seed 42" and anyone gets identical results, every time.
Core Concept #2: Parameters
Parameters control what your data looks like
| Parameter |
What it Controls |
Example |
| Count |
How many items |
100 companies |
| Distribution |
How they're arranged |
Most small, few large |
| Connections |
How items relate |
Each has 3-5 suppliers |
| Range |
Min/max values |
Employees: 10–50,000 |
Core Concept #3: Schema
Define what properties each item has
{
"company": {
"id": "string (unique ID)",
"name": "string",
"tier": "number (0-14)",
"location": "array [city, state]",
"category": "string"
}
}
Questions to Ask
- What fields do I need?
- What type is each? (string, number, boolean, date)
- Are there constraints? (price > 0, rating 0-5)
Step 1: Define Your Schema
Decide what properties your items need
const productSchema = {
id: "string",
name: "string",
price: "number",
category: "string",
inventory: "number",
rating: "number (0-5)"
};
Think About
- Essential fields only (don't over-engineer)
- What constraints apply?
- Any enum values (categories, statuses)?
Step 2: Define Distribution
Decide how many items and how they're arranged
const distribution = {
totalProducts: 1000,
categoryCounts: {
"Electronics": 300,
"Books": 400,
"Furniture": 300
},
priceRange: [10, 5000]
};
Uniform
Even distribution
Step 3: Write Generator Function
function generateProducts(count, seed) {
let rng = seed;
const products = [];
const categories = ["Electronics", "Books"];
for (let i = 0; i < count; i++) {
rng = (rng * 16807) % 2147483647;
const categoryIdx = rng % categories.length;
rng = (rng * 16807) % 2147483647;
const price = 10 + (rng % 4990);
products.push({
id: `prod-${i}`,
price: price,
category: categories[categoryIdx]
});
}
return products;
}
Step 4: Add Relationships
Connect items to create dependencies
function addReviews(products, customers, seed) {
products.forEach(product => {
rng = (rng * 16807) % 2147483647;
const reviewCount = 5 + (rng % 20);
product.reviews = [];
for (let i = 0; i < reviewCount; i++) {
rng = (rng * 16807) % 2147483647;
const custId = customers[rng % customers.length].id;
product.reviews.push({ customerId: custId });
}
});
}
Key: Use your RNG to pick existing items, creating deterministic relationships
Step 5: Export Your Data
Save in a format your app can use
JSON File
const fs = require('fs');
const data = generateProducts(
1000, 42
);
fs.writeFileSync(
'products.json',
JSON.stringify(data, null, 2)
);
JavaScript Constant
const productData = JSON.stringify(
generateProducts(1000, 42)
);
// In file:
const PRODUCTS = {...}
Workflow: Concept to Test
1. Plan
Define domain, properties, scale
5 min
2. Define
Schema, structure, parameters
10 min
3. Prototype
Small dataset (10-100 items)
15 min
4. Expand
Add relationships, parameters
10 min
5. Validate
Check errors, test seeds
5 min
6. Export
Generate & save final datasets
5 min
Pitfall #1: Non-Deterministic Randomness
❌ Bad
// Uses Date, unpredictable
return Math.random() * 100;
✅ Good
// Uses seed, reproducible
rng = (rng * 16807) % 2147483647;
return (rng / 2147483647) * 100;
Every time you generate, you want the same result.
Pitfall #2: Unrealistic Distributions
❌ Bad
// Every product has exactly
// 10 reviews
product.reviewCount = 10;
✅ Good
// Most have 5-25, some 50+
rng = (rng * 16807) % 2147483647;
product.reviewCount = 5 + (rng % 20);
Real-world data has natural variation.
Pitfall #3: Invalid Relationships
❌ Bad
// References non-existent
// customer
reviews = [{
customerId: "unknown-999"
}];
✅ Good
// References only existing
// items
const idx = rng % customers.length;
const custId = customers[idx].id;
reviews = [{ customerId: custId }];
Links must always point to real items.
Pitfall #4: No Validation
❌ Bad
// Generate, assume it works
const data = generateData(
10000, 42
);
saveToDatabase(data);
✅ Good
// Check first
const data = generateData(10000, 42);
const errors = validateData(data);
if (errors.length > 0) {
console.error(errors);
} else {
saveToDatabase(data);
}
Always validate before using.
Practical Tips
1. Start Small, Scale Later
Test with 10 items first, then 10,000
2. Use Presets for Scenarios
small (100), medium (1K), large (10K), stress (100K)
3. Make It Configurable
Let users adjust parameters in UI
4. Export Multiple Formats
JSON (API), CSV (spreadsheet), JS (constant)
Tools & Languages
JavaScript
Easiest for web. Great for visualization. Like Felementum's approach.
Python
Best for complex data. Use numpy, pandas, faker libraries.
SQL
Generate directly in database with recursive CTEs.
Choose based on where your data lives and what you're comfortable with
Summary Checklist
- Define your schema (what properties?)
- Choose distribution (how many, how arranged?)
- Implement seeded random number generator
- Write generator function (loop + create items)
- Add relationships (connections between items)
- Create presets (small/medium/large)
- Make it configurable (UI controls)
- Validate output (check for errors)
- Export in needed formats (JSON, CSV, etc)
- Document parameters and usage
- Test with different seeds
- Measure performance (generation speed)
Next Steps
1. Modify
Fork a real project and adjust parameters
2. Build
Start with 50 lines of code
3. UI
Add HTML + JavaScript controls
4. Scale
Test with 10K, 100K records
5. Share
Document for others
6. Iterate
Refine based on feedback
Questions?
Your synthetic data is only limited by your imagination and parameters!
🎲📊🔄