0

I am writing a small code to generate 101 decimal values betyween 0 and 1.01 and associate it Marcum Q-function value which is available in a csv file

import numpy as np


with open('qfunction_val.csv','rt')as f:
  data = csv.reader(f)
  for row in data:
        print(row)
        p.append(row)
r=np.arange(0,1.01,0.01)


for i in range(np.size((r))):
    q.append((p[0][i],r[i]))

When I run the code the output is as follows:

 ...
 ('0.4676987991145082', 0.32),
 ('0.4399131656732337', 0.33),
 ('0.4124631294414047', 0.34),
 ('0.3853204664075676', 0.35000000000000003),
 ('0.3584587932511938', 0.36),
 ('0.3318533464368166', 0.37),
 ('0.3054807880993974', 0.38),
 ('0.2793190344474542', 0.39),
 ('0.2533471031357998', 0.4),
 ('0.2275449766411493', 0.41000000000000003),
 ('0.2018934791418509', 0.42),
 ('0.1763741647808613', 0.43),
 ('0.1509692154967773', 0.44),
 ('0.125661346855074', 0.45),
 ('0.1004337205114698', 0.46),
 ('0.07526986209982976', 0.47000000000000003),
 ('0.05015358346473367', 0.48),
 ('0.02506890825871106', 0.49),
 ...

why is that for some values alone it has more decimal places than other.

How can i avoid it?

MSR
  • 77
  • 1
  • 3
  • 14

0 Answers0