[Matplotlib-users] Query about Programming Error

Cameron Simpson cs at cskk.id.au
Wed Dec 21 17:50:21 EST 2022


On 20Dec2022 14:14, Roberto Martin ZAMORA NEVADO <roberto.zamora1 at unmsm.edu.pe> wrote:
>I am developing a program for research purposes to enter from Tkinter
>values of mean, standard deviation and ranges, to graph a normal
>distribution, but it throws me an error of
>
>Traceback (most recent call last):
>  File "C:\Program
>Files\WindowsApps\PythonSoftwareFoundation.Python.3.10_3.10.2544.0_x64__qbz5n2kfra8p0\lib\tkinter\__init__.py",
>line 1921, in __call__
>    return self.func(*args)
>  File "g:\Cursos\Curso Básico de Python\Prueba 102", line 45, in
>Graph_Generator
>    x=np.linspace[normal(a.get()), normal(b.get()),(c.get())]
>TypeError: 'rv_continuous_frozen' object is not callable

That suggests that `normal` is a `rv_continuous_frozen` instance. That 
has a bunch of methods to obtain various things.

Looking at the docs for `scipy.stats.norm`:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.norm.html#scipy.stats.norm

It looks like your line:

     normal= stats.norm(mu,sigma)

obtains one of these objects. Based on the examples there, maybe you 
need the distribution's `.pdf` method (probablity distribution 
function)? Eg in the erroring line:

     x=np.linspace[normal(a.get()), normal(b.get()),(c.get())]

you want to say `normal.pdf(a.get())` and so forth instead of just 
`normal`?

The docs for `rv_continuous_frozen` are here:
https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.html#scipy.stats.rv_continuous
and it has a list of the methods about a screen or so down the page.
I do not know if you want the `.pdf()` method or one of the others.

Cheers,
Cameron Simpson <cs at cskk.id.au>


More information about the Matplotlib-users mailing list