how to plot uncertainty bands where each set of (x, y) data points has different x-values to be available.


The use case here is training neural network experiment (reinforcement learning) with multiple random runs. Each experiment produces a list of (x, y) data points, where x-axis is the number of environment interactions, y-axis is the performance. Due to randomness, the available x-values are different across random runs.

To simplify the problem, let us formulate it as the following toy version:

Suppose we have following data points for 3 curves

import numpy as np
import matplotlib.pyplot as plt

x1 = [0.3, 0.5, 0.7, 0.85, 0.9]
y1 = np.sin(x1)*np.exp(np.cos(x1))
x2 = [0.05, 0.12, 0.3, 0.7, 0.8]
y2 = np.sin(x2)*np.exp(0.2*np.cos(x2))
x3 = [0.2, 0.34, 0.56, 0.78, 0.89, 0.9, 0.95]
y3 = 2*np.sin(x3)*np.exp(np.cos(x3))

plt.scatter(x1, y1, label='curve1')
plt.scatter(x2, y2, label='curve2')
plt.scatter(x3, y3, label='curve3')


enter image description here

Is there a good way to plot uncertainty bands (mean plus/minus std) across different random runs ?

The first solution coming to my mind is to fit a polynomial for each curve and generate new data points for consistent x-values, but this can be very misleading in research curve. Because some of the curves might be very sparse in the data point, fitting a polynomial probably is not a good idea.

  • $\begingroup$ Welcome to our site. Could you explain exactly what these "uncertainty bands" are intended to represent? There are many possible meanings depending on how you model the curves and what you want the bands to show. $\endgroup$ – whuber Feb 13 at 13:03
  • $\begingroup$ Thanks @whuber , I'd like to plot a uncertainty bands with mean plus/minus one standard deviation (shaded area), to represent how much confidence we have for each x values. $\endgroup$ – Xingdong Zuo Feb 14 at 14:53
  • 1
    $\begingroup$ Where do you believe the uncertainty or standard deviation come from? Correct me if I'm wrong but it appears you're plotting out a curve based on an equation with no variability - for x1=0.3 your y1 will always return the same value. $\endgroup$ – Lio Elbammalf Feb 14 at 15:07
  • $\begingroup$ Please explain where your data come from, then. It is highly unusual (and surprising) to ask for confidence in "x values," because --as the software shows--those have been fixed and the y values explicitly depend on them. You need to provide some context and explain what statistical model you might have in mind. $\endgroup$ – whuber Feb 14 at 15:07
  • $\begingroup$ @whuber Oh, I am sorry for the ambiguous context. The code I provided was just to simplify the problem. The real use case I have now is I trained an Reinforcement Learning agent (in AI area) in an environment with 3 different random seeds. The x-axis is the number of interactions with the environment and y-axis is the performance of the agent. Due to randomness, the agent finishes one trial with different lengths across different random seeds, $\endgroup$ – Xingdong Zuo Feb 14 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.