benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 99138466-f5d3-5a4d-8daf-89a31b1dc21d

Problem

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

complete prompt

import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
import random
from matplotlib.axes import Axes


class ValueObject:
    value = 0

    def __init__(self, mu=0, std=1, seed=77):
        random.seed(seed)
        self.value = random.gauss(mu, std)


def task_func(obj_list) -> Axes:
    '''
    Draw the histogram and the custom normal distribution curve from the mean and standard deviation
    derived from the values of a list of ValueObjects and return the plotted Axes. For an empty list,
    the mean and the standard deviation is 0.
    
    Parameters:
    obj_list (list): The list of objects.
    attr (str): The attribute to plot.

    Returns:
    Axes: The plotted Axes.

    Requirements:
    - numpy
    - scipy.stats
    - matplotlib
    - random

    Example:
    >>> obj_list = [ValueObject(mu=23, std=77), ValueObject(mu=23, std=77, seed=222), ValueObject(mu=23, std=77, seed=333)]
    >>> ax = task_func(obj_list)
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    '''

instruct prompt

Draw the histogram and the custom normal distribution curve from the mean and standard deviation derived from the values of a list of ValueObjects and return the plotted Axes. For an empty list, the mean and the standard deviation is 0.
The function should output with:
    Axes: The plotted Axes.
You should write self-contained code starting with:

Code

import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
import random
from matplotlib.axes import Axes
class ValueObject:
    value = 0
    def __init__(self, mu=0, std=1, seed=77):
        random.seed(seed)
        self.value = random.gauss(mu, std)
def task_func(obj_list) -> Axes:

code prompt

Code

import numpy as np
import scipy.stats as stats
import matplotlib.pyplot as plt
import random
from matplotlib.axes import Axes
class ValueObject:
    value = 0
    def __init__(self, mu=0, std=1, seed=77):
        random.seed(seed)
        self.value = random.gauss(mu, std)
def task_func(obj_list) -> Axes:

entry point

task_func

libs

  • random
  • numpy
  • 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