Wenn ich eine längere Zeichenfolge habe, wie berechne ich die Wahrscheinlichkeit, ein Wort mit einer bestimmten Länge innerhalb dieser Zeichenfolge zu finden?Die Wahrscheinlichkeit eines Wortes in einer Zeichenfolge ermitteln
Bisher habe ich dies:
import math
from scipy import stats
alphabet = list("ATCG") # This is the alphabet I am working with
string = "AATCAGTAGATCG" # Here are two example strings
string2 = "TGTAAACCTTGGTTTATCG"
word = "ATCG" # This is my word
n_substrings = len(string) - len(word) # The number of possible substrings
n_substrings2 = len(string2) - len(word)
prob_match = math.pow(len(alphabet), - len(word)) # The probability of randomly choosing the word from the alphabet
# Get the probability from a binomial test?
print stats.binom_test(1, n_substrings, p=prob_match) # (Number of successes, number of trials, prob of success)
print stats.binom_test(1, n_substrings2, p=prob_match)
>>>0.0346119111615
0.0570183821615
Ist dies ein geeigneter Weg, dies zu tun, oder bin ich etwas fehlt?
Warum die unten Abstimmung bitte? – kezzos