benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7e0e9c2d-f0cc-5d8e-8ebd-67af3b7e0cb1

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import numpy as np
from scipy.optimize import curve_fit


def task_func(x, y, labels):
    """
    Fit an exponential curve to given data points and plot the curves with labels.
    It fits an exponential curve of the form: f(x) = a * exp(-b * x) + c
    to the provided x and y data points for each set of data and plots the fitted curves
    with the corresponding labels on a single matplotlib figure.

    Parameters:
    - x (list of np.ndarray): List of numpy arrays, each representing the x-values of the data points for a dataset.
    - y (list of np.ndarray): List of numpy arrays, each representing the y-values of the data points for a dataset.
    - labels (list of str): List of strings, each representing the label for a dataset.

    Returns:
    - matplotlib.figure.Figure: The figure object that contains the plotted curves.

    Requirements:
    - numpy
    - scipy.optimize

    Example:
    >>> x_data = [np.array([1,2,3]), np.array([4,5,6]), np.array([7,8,9])]
    >>> y_data = [np.array([4,5,6]), np.array([7,8,9]), np.array([10,11,12])]
    >>> labels = ['H2O', 'O2', 'CO2']
    """

instruct prompt

Fit an exponential curve to given data points and plot the curves with labels. It fits an exponential curve of the form: f(x) = a * exp(-b * x) + c to the provided x and y data points for each set of data and plots the fitted curves with the corresponding labels on a single matplotlib figure.
The function should output with:
    matplotlib.figure.Figure: The figure object that contains the plotted curves.
You should write self-contained code starting with:

Code

import numpy as np
from scipy.optimize import curve_fit
def task_func(x, y, labels):

code prompt

Code

import numpy as np
from scipy.optimize import curve_fit
def task_func(x, y, labels):

entry point

task_func

libs

  • numpy
  • scipy

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import