> For the complete documentation index, see [llms.txt](https://docs.sdv.dev/sdv/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sdv.dev/sdv/sampling/sample-realistic-data.md).

# Sample Realistic Data

Create realistic synthetic data data that follows the same format and mathematical properties as the real data. In the multi-table setting, you can also scale up (or down) the sizes of all tables in your dataset.

{% hint style="info" %}
**Sampling prerequisites.** In order to create synthetic data, make sure you have created a synthesizer and trained it on your data using the `fit` function. For more information, see the [Modeling](/sdv/modeling/single-table-synthesizers.md) docs.
{% endhint %}

### sample

Use this function to create synthetic data that mimics the real data.

```python
from sdv.utils import load_synthesizer

synthesizer = load_synthesizer(filepath='my_synthesizer.pkl')

# for multi-table synthesizers: scale the dataset up using the scale parameter
synthetic_data = synthesizer.sample(scale=1.5)

# for single-table synthesizers: input the number of row to sample
synthetic_data = synthesizer.sample(num_rows=100)

# for sequential synthesizers: input the number of sequences to generate
synthetic_data = synthesizer.sample(num_sequences=10)
```

**Parameters**: The sampling parameters and output depends on the type of data and synthesizer you have.

{% tabs %}
{% tab title="Multi Table Data" %}
**Parameters**:&#x20;

* `scale`: A float >0.0 that describes how much to scale the data by

<table data-header-hidden><thead><tr><th width="157"></th><th></th></tr></thead><tbody><tr><td>(default) <code>1</code></td><td>Don't scale the data. The model will create synthetic data that is roughly the same size as the original data.</td></tr><tr><td><code>>1</code></td><td>Scale the data by the specified factor. For example, <code>2.5</code> will create synthetic data that is roughly  2.5x the size of the original data.</td></tr><tr><td><code>&#x3C;1</code></td><td>Shrink the data by the specified percentage. For example, <code>0.9</code> will create synthetic data that is roughly 90% of the size of the original data.</td></tr></tbody></table>
{% endtab %}

{% tab title="Single Table Data" %}
**Parameters**:

* (required) `num_rows`: An integer >0 that specifies the number of rows to synthesize
* `batch_size`: An integer >0, describing the number of rows to sample at a time. If you are sampling a large number of rows, setting a smaller batch size allows you to see and save incremental progress. Defaults to the same as `num_rows`.
* `max_tries_per_batch`: An integer >0, describing the number of sampling attempts to make per batch. If you have included constraints, it may take multiple batches to create valid data. Defaults to `100`.
* `output_file_path`: A string describing a CSV filepath for writing the synthetic data. Specify to `None` to skip writing to a file. Defaults to `None`.
  {% endtab %}

{% tab title="Sequential Data" %}
**Parameters**:

* (required) `num_sequences`: An integer >0 describing the number of sequences to sample
* `sequence_length`: An integer >0 describing the length of each sequence. If you provide `None`, the synthesizer will determine the lengths algorithmically, and the length may be different for each sequence. Defaults to `None`.
  {% endtab %}
  {% endtabs %}

**Returns** Synthetic data. The synthetic data is the same format as the original data. This will be a single pandas DataFrame for single table data, or a dictionary of pandas DataFrames for multi-table data.

{% hint style="info" %}
**How does scaling work for multi-table data?** During the fitting process, your SDV synthesizer learns the size of each data table. This is assumed to be a scale of 1. Scaling the entire dataset up or down means that the size of each table will change proportionally based on the original data size.&#x20;

Note that some synthesizers may perform small, additional algorithmic calculations to determine the final size of each table. However, you can still expect the final synthetic data to approximately follow the scale of the real data (with some minor deviations).
{% endhint %}

### reset\_sampling

Use this function to reset any randomization in sampling. After calling this, your synthesizer will generate the same data as before. For example in the code below, `synthetic_data1` and `synthetic_data2` are the same.

```python
synthesizer.reset_sampling()
synthetic_data1 = synthesizer.sample(scale=1.5)

synthesizer.reset_sampling()
synthetic_data2 = synthesizer.sample(scale=1.5)
```

**Parameters** None

**Returns** None. Resets the synthesizer.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.sdv.dev/sdv/sampling/sample-realistic-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
