我的函数 mutateSequence 接受三个参数。参数p是0和1之间的值,包括0和1。我需要两个 if 语句,一个以 4p/5 的概率输入,另一个以 p/5 的概率输入。我该如何编写逻辑来实现这一点?
代码:
void mutateSequence(vector<pair<string, string>> v, int k, double p)
{
for (int i = 0; i < k - 1; i++)
{
string subjectSequence = v[i].second;
for (int j = 0; j < subjectSequence.length(); j++)
{
// with probability 4p/5 replace the nucelotide randomly
if (//enter with probability of 4p/5)
{
//do something
}
if (//enter with probability of p/5)
{
//do something
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
我期望第一个 if 语句以 4p/5 …