--Measuring a number of times as a sensor --This time is known to follow an exponential distribution --Sensor malfunction may return less than the correct time. However, you can tell if something went wrong. --I want to know the average of the original time from the measured values
It may be obtained so that the probability of becoming the estimated value is maximized. Specifically, the following equation. However, in the case of a defect, it is considered that the upper limit has been reached.
$ Original average = \ frac {total of all data} {number of data-number of limits reached} $
python3
import numpy as np
np.random.seed(1)
n = 100000 #The number of data
a = np.random.exponential(3, n) #Original distribution
print('Average of the original distribution%.3f'%a.mean())
b = np.random.uniform(2, 10, n) #upper limit
c = np.min((a, b), 0) #Distribution with upper limit
nn = (c==b).sum() #Number reached the upper limit
print('Estimated mean of the original distribution%.3f'%(c.sum()/(n-nn)))
>>>
Mean of original distribution 2.996
Estimated mean of the original distribution 2.996
that's all
Recommended Posts