1 from statistics import binoms 2 n = 19 3 k = np.arange(0, n + 1) ImportError: cannot…
- User
1 from statistics import binoms 2 n = 19 3 k = np.arange(0, n + 1)
ImportError: cannot import name 'binoms' from 'statistics' (D:\Anaconda3\Lib\statistics.py)
- Assistant
The error you encountered indicates that you're trying to import a function or module named
binomsfrom thestatisticsmodule in Python, but such a function does not exist in the standardstatisticslibrary. Thestatisticsmodule provides functions for statistical calculations, but it does not include binomial functions.If you're looking to work with binomial distributions, you should use the
scipylibrary, which has abinomclass in thescipy.statsmodule for working with binomial distributions. Here’s how you can set it up:-
Make sure you have the
scipylibrary installed. If you don't have it installed, you can install it via pip:bashpip install scipy
-