benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b66ca888-7aef-58c2-86e1-e4a31fa4fba9

Problem

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

complete prompt

import matplotlib.pyplot as plt
from scipy.optimize import curve_fit


def task_func(X, Y):
    """
    Adjust a quadratic function to the given data (X, Y) and plot the data along with the fit.

    Parameters:
    - X (list or numpy.array): The X data points.
    - Y (list or numpy.array): The Y data points.

    Returns:
    tuple:
    - list: The optimized parameters of the quadratic function (a, b, c).
    - matplotlib.axes.Axes: The plot showing the scatter data points and the quadratic fit.

    Requirements:
    - matplotlib.pyplot
    - scipy.optimize.curve_fit

    Example:
    >>> import numpy as np
    >>> np.random.seed(42)
    >>> X = np.linspace(-10, 10, 100)
    >>> Y = 3*X**2 + 2*X + 1 + np.random.normal(0, 20, len(X))
    >>> params, ax = task_func(X, Y)
    >>> params
    [3.0366511660907975, 2.1379326607136035, -2.3233168384548284]
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    """

instruct prompt

Adjust a quadratic function to the given data (X, Y) and plot the data along with the fit.
The function should output with:
    tuple:
    list: The optimized parameters of the quadratic function (a, b, c).
    matplotlib.axes.Axes: The plot showing the scatter data points and the quadratic fit.
You should write self-contained code starting with:

Code

import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
def task_func(X, Y):

code prompt

Code

import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
def task_func(X, Y):

entry point

task_func

libs

  • matplotlib
  • 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