> 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. This function is available for single- and multi-table synthesizers. For sequential syntheizers, please see the sample\_sequences function below.

```python
from sdv.utils import load_synthesizer

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

synthetic_data = synthesizer.sample(num_rows=100)
```

**Parameters**:

* (required) `num_rows`: An integer >0 that specifies the number of rows to synthesize
* (required for multi-table) `main_table_name`: A string containing the name of the main table from the dataset. This is require for multi-table datasets. In this case, the `num_rows` you specify will apply to the main table, and all the other table will be scaled up or down algorithmically in relation to this table.
* `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.&#x20;
  * (default) 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.
  * (default)  `100`.
* `output_folder_path`: A string describing the name of a folder for writing the synthetic data. If provided, the synthetic data will be written as CSV files inside the folder. Each CSV file will correspond to a table, named as `<table_name>.csv`.
  * (deafult) `None`: Do not write the synthetic data to files.

### sample\_scale

Use this function to create synthetic data that is scaled up or down for multi-table datasets. This function is only available for multi-table synthesizers.

```python
from sdv.utils import load_synthesizer

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

synthetic_data = synthesizer.sample_scale(scale=2.5)
```

**Parameters**:

* (required) `scale`: A float >0.0 that describes how much to scale the data by
  * (default) `1`: Don't scale the data. The model will create synthetic data that is roughly the same size as the original data.
  * `>1`: Scale the data by the specified factor. For example, `2.5` will create synthetic data that is roughly  2.5x the size of the original data.
  * `<1`: Shrink the data by the specified percentage. For example, `0.9` will create synthetic data that is roughly 90% of the size of the original data.

**Returns:** Synthetic data. The synthetic data is the same format as the original data, which is dictionary mapping the table name to a pandas DataFrame containing the data for it.

{% 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 %}

### sample\_sequences

Use this function to create synthetic data for sequential data. This function is only available for sequential synthesizers.

**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`.

### 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(num_rows=100)

synthesizer.reset_sampling()
synthetic_data2 = synthesizer.sample(num_rows=100)
```

**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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
