> ## Documentation Index
> Fetch the complete documentation index at: https://aegean.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Conditional generator p(x|z)

> Generating samples from a complex distribution by transforming simple Gaussians.

Example of generating samples from a complex distribution by feeding to a function bivariate Gaussians. The function can be implemented by a neural network.

```python theme={null}
import numpy as np
import matplotlib.pyplot as plt


def generate_half_moon(num_points, radius, width):
    # Generate points on a circle
    theta = np.linspace(0, np.pi, num_points)
    x_circle = radius * np.cos(theta)
    y_circle = radius * np.sin(theta)

    # The function changes the mean of the standard normal distribution
    x_noisy = x_circle + np.random.normal(0, width, num_points)
    y_noisy = y_circle + np.random.normal(0, width, num_points)

    # Combine x and y coordinates
    half_moon_points = np.column_stack((x_noisy, y_noisy))

    return half_moon_points


# Example usage:
half_moon_data = generate_half_moon(num_points=1000, radius=1.0, width=0.1)

plt.scatter(half_moon_data[:, 0], half_moon_data[:, 1])
plt.xlabel("X-axis")
plt.ylabel("Y-axis")
plt.title("Generated Half-Moon")
plt.show()
```

<img src="https://mintcdn.com/aegeanaiinc/xyxAL8JMAK6wgqoN/aiml-common/lectures/vae/introduction/x-given-z-generator/images/cell_1_output_1.png?fit=max&auto=format&n=xyxAL8JMAK6wgqoN&q=85&s=ec4bd129de9aeabefea857cee7348cfd" alt="Generated half-moon shape from transformed Gaussians" width="587" height="455" data-path="aiml-common/lectures/vae/introduction/x-given-z-generator/images/cell_1_output_1.png" />

***

<Callout icon="pen-to-square" iconType="regular">
  [Edit this page on GitHub](https://github.com/aegean-ai/eaia/edit/main/src/aiml-common/lectures/vae/introduction/x-given-z-generator/x_given_z_generator_example.mdx) or [file an issue](https://github.com/aegean-ai/eaia/issues/new/choose).
</Callout>
