benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 28c9c96e-1187-5d6e-b871-2e832012c515

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 import stats import matplotlib.pyplot as plt def task_func(mu=0, sigma=1, sample_size=1000, seed=0): """ Generate a sample from a normal distribution with a given mean and a standard deviation and plot the histogram together with the probability density function. Returns the Axes object representing the plot and the empirical mean and standard deviation of the sample. Parameters: - mu (float): The mean of the normal distribution. Default is 0. - sigma (float): The standard deviation of the normal distribution. Default is 1. - sample_size (int): The size of the sample to generate. Default is 1000. Returns: - ax (matplotlib.axes._axes.Axes): Axes object with the plotted histogram and normal PDF, with the title format of 'Normal Distribution with $\\mu = %0.2f, \\sigma = %0.2f$'. - float: The empirical mean of the sample. - float: The empirical standard deviation of the sample. Requirements: - numpy for data generation. - scipy.stats for statistical functions. - matplotlib.pyplot for plotting. Example: >>> ax, mean, std = task_func(0, 1, 1000) >>> type(ax) <class 'matplotlib.axes._axes.Axes'> >>> print(round(mean, 3)) -0.045 >>> print(round(std, 3)) 0.987 """
Plain-text mathematical notation (without MathML)
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt


def task_func(mu=0, sigma=1, sample_size=1000, seed=0):
    """
    Generate a sample from a normal distribution with a given mean and a standard deviation and plot the histogram 
    together with the probability density function. Returns the Axes object representing the plot and the empirical
    mean and standard deviation of the sample.

    Parameters:
    - mu (float): The mean of the normal distribution. Default is 0.
    - sigma (float): The standard deviation of the normal distribution. Default is 1.
    - sample_size (int): The size of the sample to generate. Default is 1000.

    Returns:
    - ax (matplotlib.axes._axes.Axes): Axes object with the plotted histogram and normal PDF, with the title format of 'Normal Distribution with $\\mu = %0.2f, \\sigma = %0.2f$'.
    - float: The empirical mean of the sample.
    - float: The empirical standard deviation of the sample.

    Requirements:
    - numpy for data generation.
    - scipy.stats for statistical functions.
    - matplotlib.pyplot for plotting.

    Example:
    >>> ax, mean, std = task_func(0, 1, 1000)
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    >>> print(round(mean, 3))
    -0.045
    >>> print(round(std, 3))
    0.987
    """
Original LaTeX notation
import numpy as np
from scipy import stats
import matplotlib.pyplot as plt


def task_func(mu=0, sigma=1, sample_size=1000, seed=0):
    """
    Generate a sample from a normal distribution with a given mean and a standard deviation and plot the histogram 
    together with the probability density function. Returns the Axes object representing the plot and the empirical
    mean and standard deviation of the sample.

    Parameters:
    - mu (float): The mean of the normal distribution. Default is 0.
    - sigma (float): The standard deviation of the normal distribution. Default is 1.
    - sample_size (int): The size of the sample to generate. Default is 1000.

    Returns:
    - ax (matplotlib.axes._axes.Axes): Axes object with the plotted histogram and normal PDF, with the title format of 'Normal Distribution with $\\mu = %0.2f, \\sigma = %0.2f$'.
    - float: The empirical mean of the sample.
    - float: The empirical standard deviation of the sample.

    Requirements:
    - numpy for data generation.
    - scipy.stats for statistical functions.
    - matplotlib.pyplot for plotting.

    Example:
    >>> ax, mean, std = task_func(0, 1, 1000)
    >>> type(ax)
    <class 'matplotlib.axes._axes.Axes'>
    >>> print(round(mean, 3))
    -0.045
    >>> print(round(std, 3))
    0.987
    """

instruct prompt

Generate a sample from a normal distribution with a given mean and a standard deviation and plot the histogram together with the probability density function. Returns the Axes object representing the plot and the empirical mean and standard deviation of the sample. The function should output with: ax (matplotlib.axes._axes.Axes): Axes object with the plotted histogram and normal PDF, with the title format of 'Normal Distribution with $\\mu = %0.2f, \\sigma = %0.2f$'. float: The empirical mean of the sample. float: The empirical standard deviation of the sample. You should write self-contained code starting with:
Plain-text mathematical notation (without MathML)
Generate a sample from a normal distribution with a given mean and a standard deviation and plot the histogram together with the probability density function. Returns the Axes object representing the plot and the empirical mean and standard deviation of the sample.
The function should output with:
    ax (matplotlib.axes._axes.Axes): Axes object with the plotted histogram and normal PDF, with the title format of 'Normal Distribution with $\\mu = %0.2f, \\sigma = %0.2f$'.
    float: The empirical mean of the sample.
    float: The empirical standard deviation of the sample.
You should write self-contained code starting with:
Original LaTeX notation
Generate a sample from a normal distribution with a given mean and a standard deviation and plot the histogram together with the probability density function. Returns the Axes object representing the plot and the empirical mean and standard deviation of the sample.
The function should output with:
    ax (matplotlib.axes._axes.Axes): Axes object with the plotted histogram and normal PDF, with the title format of 'Normal Distribution with $\\mu = %0.2f, \\sigma = %0.2f$'.
    float: The empirical mean of the sample.
    float: The empirical standard deviation of the sample.
You should write self-contained code starting with:

Code

import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
def task_func(mu=0, sigma=1, sample_size=1000, seed=0):

code prompt

Code

import numpy as np
from scipy import stats
import matplotlib.pyplot as plt
def task_func(mu=0, sigma=1, sample_size=1000, seed=0):

entry point

task_func

libs

  • 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