使用R找出最大化对数似然的λ

时间:2018-08-03 13:19:20

标签: r

问题:找到使对数似然最大化的λ

提供的代码:

  

loglikelihood <-function(lambda){sum(dpois(counts,lambda,log = T))}

     

lambdas <-seq(1,15,len = 300)

     

result <-sapply(lambdas,loglikelihood)

到目前为止,我使用代码发现了lambda位置

  

哪个(结果==最大(结果))

[1] 62

我不知道要使用什么代码来使用Lambda(值)在第62位提取Lambda

1 个答案:

答案 0 :(得分:0)

for dicm in re.finditer(b'Content-Length:', mime_bytes_msg):

    content_length_index = dicm.end() + 1
    content_length = ''

    dicom_file = open('%s/%s_%d.dcm' % (output_path, dicom_prefix, instance_number), 'wb')
    instance_number += 1
    while mime_bytes_msg[content_length_index:content_length_index + 1].decode('utf-8').isdigit():
        content_length += mime_bytes_msg[content_length_index:content_length_index + 1].decode('utf-8')
        content_length_index += 1

    dicom_start_index = content_length_index + 4
    dicom_file.write(mime_bytes_msg[dicom_start_index:dicom_start_index + int(content_length)])

    dicom_file.close()

我认为这会起作用。但是我没有进行测试,因为没有可重现的示例。

相关问题