benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 6fe90a00-5065-5ec3-bd14-9d6309fdb19f

Problem

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

complete prompt

import numpy as np
import matplotlib.pyplot as plt


def task_func(data: np.ndarray) -> plt.Axes:
    """
    Plots the cumulative probability distribution of a given NumPy array of numbers,
    representing how the cumulative probability increases with the sorted data indexes.

    Parameters:
    - data (numpy.ndarray): The input NumPy array of non-negative numbers.

    Returns:
    - matplotlib.pyplot.Axes: The plot of cumulative probabilities.

    Requirements:
    - numpy
    - matplotlib

    Raises:
    - ValueError: If the input array contains negative numbers or NaNs.
    - TypeError: If the input array contains non-numeric inputs.

    Note:
    - In case of an all-zeros input, the cumulative probability remains at 0 across all indexes.
    - The plot uses marker ('o') and a solid line ('-') for the cumulative probability curve.
    - The plot is titled "Cumulative Probability Plot", with "Index" on the x-axis and
      "Cumulative Probability" on the y-axis.

    Example:
    >>> ax = task_func(np.array([1, 2, 3, 4, 5]))
    >>> ax.get_title()
    'Cumulative Probability Plot'
    """

instruct prompt

Plots the cumulative probability distribution of a given NumPy array of numbers, representing how the cumulative probability increases with the sorted data indexes.
Note that: In case of an all-zeros input, the cumulative probability remains at 0 across all indexes. The plot uses marker ('o') and a solid line ('-') for the cumulative probability curve. The plot is titled "Cumulative Probability Plot", with "Index" on the x-axis and "Cumulative Probability" on the y-axis.
The function should raise the exception for: ValueError: If the input array contains negative numbers or NaNs. TypeError: If the input array contains non-numeric inputs.
The function should output with:
    matplotlib.pyplot.Axes: The plot of cumulative probabilities.
You should write self-contained code starting with:

Code

import numpy as np
import matplotlib.pyplot as plt
def task_func(data: np.ndarray) -> plt.Axes:

code prompt

Code

import numpy as np
import matplotlib.pyplot as plt
def task_func(data: np.ndarray) -> plt.Axes:

entry point

task_func

libs

  • numpy
  • matplotlib

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