<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Content and Objective
Show result of "taxi problem"
Step1:  Parameters
Step2:  Observe and Estimate Using Max-Estimator
First using $\hat{N}=\max{x_1,..., x_k}$, equalling ML estimation since
Step3:  Show Results for Additional Estimators
Additional esimators
$\hat{N}=\max{x_1,...,x_K}+\min{x_1,...,x_K}$
$\hat{N}=2\cdot \frac{1}{K}( x_1+ \cdots+ x_K)$
<ASSISTANT_TASK:>
Python Code:
# importing
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
# showing figures inline
%matplotlib inline
# plotting options 
font = {'size'   : 30}
plt.rc('font', **font)
plt.rc('text', usetex=True)
matplotlib.rc('figure', figsize=(30, 15) )
Explanation: Content and Objective
Show result of "taxi problem":
Given $\Omega={1,...,N}$ 
Observe $K$ samples $X_1=x_1, ..., X_K=x_K$ (assumed to be different)
Estimate for $N$ based on the samples: $$\hat{N}=S(x_1,...,x_K)$$
Method: Sample groups and get estimator
End of explanation
# define (unknown) group size
N = 1000#np.random.randint( 1000 )
taxis = [ t for t in range( N ) ]
# size of subgroup to be observed
M = N // 10
# number of observations
N_obser = int( 1e3 )
# allowing for multiple observations (Modus Operandi: same number twice)?
MO = 0
# Sample distances used in order statistics for doing quantils
Q = 10
Explanation: Parameters
End of explanation
# initialize array for collecting several estimations to evaluate bias of estimator
estimators = np.zeros( N_obser )
for _k in range( N_obser ):        
    
    sample = np.random.choice( taxis, replace=MO )
    
    estimators[ _k ] = np.max( sample )
    
# get sample average and compare to true value
print('True value: {}'.format( N ) )
print('Average estimate: {}'.format( np.average( estimators ) ) )
Explanation: Observe and Estimate Using Max-Estimator
First using $\hat{N}=\max{x_1,..., x_k}$, equalling ML estimation since:
$$
P(X_1=x_1,\ldots, X_K=x_K|N)
=
\prod\limits_{i=1}^K P(X_i=x_i|N)
=
\begin{cases}
\left( \frac{1}{N}\right)^K , & x_1\leq N, \ldots, x_K\leq N
\
0, & \text{ otherwise}
\end{cases}
.
$$
Thus, prob. is maximized if $N$ is chose to be as small as possible, corresponding to the largest $x_i$
Show true group size and sample mean of estimation
End of explanation
# define range of group size to be analyzed
group_sizes = range( 1, N//10, 5 )
# initialize arrays for collecting estimator values
est_max = np.zeros_like( group_sizes )
est_maxmin = np.zeros_like( group_sizes )
#est_quantiles = np.zeros_like( group_sizes )
est_avg = np.zeros_like( group_sizes )
# loop for group sizes
for ind_gs, val_gs in enumerate( group_sizes ):
    
    # initialize array for collecting several estimations to evaluate bias of estimator
    estimators_max = np.zeros( N_obser )
    estimators_maxmin = np.zeros( N_obser )
    estimators_avg = np.zeros( N_obser )
    #estimators_quantiles = np.zeros( N_obser )
    
    # loop for realizations
    for _k in range( N_obser ):        
        # sample and get estimator
        sample = np.random.choice( taxis, size = val_gs,  replace = MO )
        
        estimators_max[ _k ] = np.max( sample )
        estimators_maxmin[ _k ] = np.max( sample ) + np.min( sample )
        
        #estimators_quantiles[ _k ] = np.sort( sample )[ -Q ] + np.sort( sample )[ Q ]
        estimators_avg[ _k ] = 2 * np.average( sample )
    # find average value of estimation for given group size
    est_max[ ind_gs ] = np.average( estimators_max )
    est_maxmin[ ind_gs ] = np.average( estimators_maxmin )
    est_avg[ ind_gs ] = np.average( estimators_avg )
    #est_quantiles[ ind_gs ] = np.average( estimators_quantiles )
plt.figure()
plt.plot( group_sizes, est_max, label='$\hat{E}( \\max(X_1,\ldots,X_K) )$' ) 
plt.plot( group_sizes, est_maxmin, label='$\hat{E}( \\max(X_1,\ldots,X_K) + \\min(X_1,\ldots,X_K)  )$' ) 
plt.plot( group_sizes, est_avg, label='$\hat{E}( \\frac{2}{K}\sum_{i=1}^K X_i)$' ) 
#plt.plot( group_sizes, est_quantiles, label='$\hat{E}( X_{(Q)} + X_{(K-Q)}  )$' ) 
plt.grid(True)
plt.legend( loc='best' )
plt.title('N = {}'.format(N) )
plt.xlabel('$K$')
Explanation: Show Results for Additional Estimators
Additional esimators
$\hat{N}=\max{x_1,...,x_K}+\min{x_1,...,x_K}$
$\hat{N}=2\cdot \frac{1}{K}( x_1+ \cdots+ x_K)$
End of explanation
<END_TASK>