<｜begin▁of▁sentence｜>### Instruction:
How do you use RDPGEstimator from graspologic to fit a Random Dot Product Graph (RDPG) model to a random networkx graph and visualize the estimated probability matrix?
### Response:
import numpy as np
from graspologic.models import RDPGEstimator
import networkx as nx

# Create a random graph
n = 200
m = 400
G = nx.gnm_random_graph(n, m)

# Convert to adjacency matrix
A = nx.to_numpy_array(G)

# Instantiate and fit the RDPG model
rdpg = RDPGEstimator(loops=False, n_components=5)
rdpg.fit(A)

# Access the estimated latent positions
latent_positions = rdpg.latent_tuple_

# Visualize the probability matrix
import matplotlib.pyplot as plt
plt.imshow(rdpg.p_mat_, cmap='viridis')
plt.colorbar()
plt.title('Estimated Probability Matrix')
plt.show()
<|EOT|>
