0

I have some polar [R,theta] data, that I want to express as a pdf.

As I understand it, I simply normalize the data, so its integral is 1.

I am using numpy.trapz() method, but am a bit unsure of the syntax.

The code below shows what I have tried, I expect the outputs to be in a range ( 0, 1 > but they seem a bit high.

Am I using .trapz() method correctly?
Is .trapz() appropriate for circular data?

theta = np.linspace( -np.pi, np.pi, 50 )
r     = np.array([  1.23445554e-02,   3.03557798e-02,   7.02699393e-02,
                    1.51352457e-01,   3.00238850e-01,   5.43818199e-01,
                    8.93133849e-01,   1.32293971e+00,   1.76077447e+00,
                    2.10102936e+00,   2.24555703e+00,   2.15016660e+00,
                    1.84666100e+00,   1.42543142e+00,   9.91689535e-01,
                    6.24126941e-01,   3.56994042e-01,   1.86663166e-01,
                    8.98562553e-02,   4.01629846e-02,   1.68354083e-02,
                    6.69424846e-03,   2.55748908e-03,   9.52021934e-04,
                    3.50547486e-04,   1.29726513e-04,   4.90546282e-05,
                    1.92776373e-05,   8.00850696e-06,   3.57673721e-06,
                    1.74551297e-06,   9.45084654e-07,   5.75501932e-07,
                    3.98658528e-07,   3.16843272e-07,   2.90421340e-07,
                    3.07486145e-07,   3.75264328e-07,   5.25073662e-07,
                    8.35385632e-07,   1.49531795e-06,   2.97409444e-06,
                    6.48232116e-06,   1.52539070e-05,   3.81503341e-05,
                    9.97843762e-05,   2.68504223e-04,   7.31213584e-04,
                    1.98302971e-03,   5.27234229e-03
                    ]
                 )

r_pdf = r / np.trapz( r, x = theta )

print r_pdf.max()


fig = plt.figure()
ax  = fig.add_subplot( 111, polar = True )

ax.plot( theta, r,     lw = 3 )
ax.plot( theta, r_pdf, lw = 3 )
user3666197
  • 1
  • 6
  • 50
  • 92
Dave
  • 1,170
  • 3
  • 20
  • 30
  • 1
    `I expect the outputs to be in the range 0-1 but they seem a bit high`. Note that this is a common misconception: The probability of an event A `P(A)` cannot be larger than `1`. This is not true for probability density. A good example to see this is considering a uniform distribution with a range of `[0, 0.5]`. Since the `pdf` is normed, the integral of the density between `0` and `0.5` has to be `1`. If you calculate the Integral you will see that the density is in fact `2` :) – cel Mar 14 '15 at 07:08
  • I don't think so, integral of 1/(b-a) between 0, 0.5 is 1. – Dave Mar 14 '15 at 11:26
  • 2
    What exactly do you think is wrong? Of course the integral is 1 - That's because the uniform distribution is a proper probability distribution. But that's not the point here. The point is, that `p(1/(b-a))` = `p(1/0.5)` = `2` > `1`. – cel Mar 14 '15 at 11:42
  • ok I see what you mean. It's just semantics then, you mean that when the distribution is evaluated it can be > 1, to me calculating an integral means doing the integration :) but thanks still very helpful. – Dave Mar 14 '15 at 13:00

0 Answers0