См. Ниже определение функции. Я применяю к нему вход, который является вектором.Я ожидаю вектор в выводе, и я не получаю его.Почему?См. Командная строка ниже:
>> function ret_val = succesPerBlockAndCorBitVal( corrected_bits,
good_bits_rate, total_num_of_bits )
if corrected_bits == 0 #corner case
ret_val = power( good_bits_rate, total_num_of_bits ) ;
else
bad_bits_rate = 1 - good_bits_rate ;
non_corrected_bits = total_num_of_bits - corrected_bits ;
maxy = max( non_corrected_bits, corrected_bits ) ;
miny = min( non_corrected_bits, corrected_bits ) ;
over_vect= 1:total_num_of_bits ;# This is the nominator factorial vector.
under_vect=[1:miny , 1:maxy ] ;# This is the denomnator factorial vector
ret_val = over_vect ./ under_vect ; # Now we have a vector which all elements' product is the factorial. However, for high double digits
#numbers this will be out bounds. Therefore, it will first be element-wise multiplied with the probabilities' vector.
succc_fail_vect = [ones(1,corrected_bits) * bad_bits_rate , ones( 1, total_num_of_bits - corrected_bits ) * good_bits_rate ] ;
#The product of this vector is the probability of exactly 1 permutation of having exactly corrected number of bits bad.
#A. The product of the resultany vector would be the result
ret_val = prod( ret_val .* succc_fail_vect ) ; #By multiplying the pemutation vector with the succc_fail_vect, we know that:
endif
endfunction
succesPerBlockAndCorBitVal( 0:4, 0.99, 10 )
ans = 9.043820750088043e-01