log_likelihood := ( theta, s ) -> s * log( theta ) + ( n - s ) * log( 1 - theta ); log_likelihood( theta, s ); # s * ln( theta ) + ( n - s ) * ln( 1 - theta ) diff( log_likelihood( theta, s ), theta ); # s / theta - ( n - s ) / ( 1 - theta ) simplify( diff( log_likelihood( theta, s ), theta ) ); # ( n * theta - s ) / ( theta * ( - 1 + theta ) ) solve( diff( log_likelihood( theta, s ), theta ) = 0, theta ); # s / n this is the MLE theta_hat of theta simplify( - diff( log_likelihood( theta, s ), theta$2 ) ); # ( n * theta^2 - 2 * s * theta + s ) / ( theta^2 * ( -1 + theta )^2 ) simplify( eval( - diff( log_likelihood( theta, s ), theta$2 ), theta = s / n ) ); # n^3 / ( ( n - s ) * s ) this is the Fisher information simplify( eval( 1 / sqrt( - diff( log_likelihood( theta, s ), theta$2 ) ), theta = s / n ) ); # 1 / sqrt( n^3 / ( ( n - s ) * s ) ) this is SE_hat( theta_hat )