[Chennaipy] Query on numpy.logspace() in Python

Nithya Duraisamy nithyadurai87 at gmail.com
Tue Jul 6 06:53:11 EDT 2021


Thanks Rajeshkumar.

செவ்., 6 ஜூலை, 2021, பிற்பகல் 1:56 அன்று, rajeshkumar p
<gprkumar at gmail.com> எழுதியது:
>
>
> Hi,
>
> The below snippet will add few info:
>
> >>> import numpy as np
> >>> np.logspace(2, 4, num=1, base=10)
> array([100.])
>
> # Our result is 10**2
>
> >>> np.logspace(2, 4, num=2, base=10)
> array([  100., 10000.])
>
> # Our result is 10**2, 10**3
>
>
> >>> np.logspace(2, 4, num=3, base=10)
> array([  100.,  1000., 10000.])
>
> # Our result is 10**2, 10**3, 10**4
>
>
> >>> np.logspace(2, 4, num=4, base=10)
> array([  100.        ,   464.15888336,  2154.43469003, 10000.        ])
>
>
>
> >>> np.linspace(2, 4, num=4)
> array([2.        , 2.66666667, 3.33333333, 4.        ])
> >>> np.power(10, np.linspace(2, 4, num=4))
> array([  100.        ,   464.15888336,  2154.43469003, 10000.        ])
>
>
> ### Observation:
> ### np.power(10, np.linspace(2, 4, num=4)) is the same as np.logspace(2, 4, num=4, base=10).
>
> Hope this helps.
>
> regards,
> Rajeshkumar P
>
> On Tue, 6 Jul 2021 at 12:48, Nithya Duraisamy <nithyadurai87 at gmail.com> wrote:
>>
>> >
>> > It’s because you are looking at log space. Try linspace if you want it in between the numbers.
>>
>>
>> What is mean by log space?
>>
>> Where to read about that?
>> _______________________________________________
>> Chennaipy mailing list
>> Chennaipy at python.org
>> https://mail.python.org/mailman/listinfo/chennaipy
>
> _______________________________________________
> Chennaipy mailing list
> Chennaipy at python.org
> https://mail.python.org/mailman/listinfo/chennaipy


More information about the Chennaipy mailing list