Решаю задачи по физике, математике. Пишу посты по естественным и точным наукам, а также программированию.
понедельник, 13 декабря 2021 г.
вторник, 15 июня 2021 г.
Rewriting the recursive algorithm iteratively in python
import sys
sys.setrecursionlimit(1500)
Any recursive function can be made to iterate (into a loop) but you need to use a stack yourself to keep the state.
Normally, tail recursion is easy to convert into a loop:
A(x) {
if x<0 return 0;
return something(x) + A(x-1)
}
Can be translated into:
A(x) {
temp = 0;
for i in 0..x {
temp = temp + something(i);
}
return temp;
}
Other kinds of recursion that can be translated into tail recursion are also easy to change. The other require more work.
The following:
treeSum(tree) {
if tree=nil then 0
else tree.value + treeSum(tree.left) + treeSum(tree.right);
}
Is not that easy to translate. You can remove one piece of the recursion, but the other one is not possible without a structure to hold the state.
treeSum(tree) {
walk = tree;
temp = 0;
while walk != nil {
temp = temp + walk.value + treeSum(walk.right);
walk = walk.left;
}
}
понедельник, 14 июня 2021 г.
Human Phenotype Ontology
https://github.com/davetang/human_phenotype_ontology/blob/master/README.md
https://www.taylorfrancis.com/books/mono/10.1201/b10967/introduction-bio-ontologies-peter-robinson-sebastian-bauer
четверг, 31 октября 2019 г.
EDA
EDA
Программирование
pandas DataFramesparse matrices
Теория
1) Обзор методов классификации по содержанию этой книжки.
2) Практика Linear classification - смотри topic4 тут.
3) Подробнее про linear и logistic regression тут.
4) Bagging, Random Forest, Feature Importance, Gradient boosting - 3 неделя mlcourse.
Какие бывают распределения, давно хочу расписать, скажем, в виде плаката: тут и тут
пятница, 8 марта 2019 г.
binary classification test
понедельник, 3 апреля 2017 г.
Певзнер. Задачи.
2.2)
m = [8, 4, 6] res = ''for i0 in range(m[0]+1): res += str(i0) for i1 in range(m[1]+1): res += str(i1) for i2 in range(m[2] + 1): res += str(i2) print(res) def recursion(iter_num, iter_val, res): if iter_num < len(m): if iter_val <= m[iter_num]: res += str(iter_val) res = recursion(iter_num + 1, 0, res) return recursion(iter_num, iter_val + 1, res) else: return res else: return res print(recursion(0, 0, ''))
2.3) да нет нет
2.17) бактерий на k-ом шаге будет 2^k n - 2^k k. Отсюда видно, что через n шагов все бактерии будут съеден
2.18) как? 99*2 только если сразу попадется правдивей
2.19)
воскресенье, 26 февраля 2017 г.
Enumerating k-mers Lexicographically (ROSALIND LEXF)
Return: All strings of length n that can be formed from the alphabet, ordered lexicographically.
s = input() n = int(input()) alphabet = s.split(' ') def cycle(res, k): if k > 1: new_res = [] for r in range(len(res)): for i in alphabet: new_res.append(res[r] + i) return cycle(new_res, k-1) else: return res for i in cycle(alphabet, n): print(i)