自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

掉下个小石头

jump jump jump...

  • 博客(318)
  • 资源 (7)
  • 收藏
  • 关注

原创 Patricia Trie与Radix Trie的不同

在StackExchange上有这样一个问题—What is the difference between radix trees and Patricia tries?(原问题)。然而,该问题下的回答并没有说明白这俩算法的区别。不仅如此,网上所有的相关资料都认为这俩是一样的,除了名字。Radix Tree关于Radix Tree,可以参考Wikipedia上的讲解。In computer science, a radix tree (also radix trie or compact prefi

2021-04-02 11:51:08 1041

原创 等概率随机分配彩票问题

#include <vector>using namespace std;#define bkt_num 10double stat[bkt_num][bkt_num] = { 0 };double func(int i){ double result = 0;}int main(){ for (int i = 0; i < bkt_num - ...

2020-03-12 23:17:02 418

原创 跳表代码

跳表根据逐层元素减半的方式,能够对有序链表进行快速的插入,查找,删除等操作。skip_list.h声明#define MAX_LEVEL 8typedef struct Node_s{ int value; struct Node_s *next[1];}Node;typedef struct SkipList_s{ int level; Node *head;}Ski...

2020-02-29 17:54:13 375

原创 MIT AI Memo 239 - HakMem 算法解析

该算法用于计算整数中1的个数。首先,来看一个整数的性质若m=xnkn+xn−1kn−1+...+x1k1+x0m = x_nk^n+x_{n-1}k^{n-1}+...+x_1k^1+x_0m=xn​kn+xn−1​kn−1+...+x1​k1+x0​则m%(k−1)=(xn+xn−1+...+x1+x0)%(k−1)m \% (k-1) = (x_n+x_{n-1}+...+x_1+...

2020-02-29 17:37:06 379

原创 等比例的对比

十里挑一和百里挑十拿个更优秀呢?做个试验,具体来比较一下十里挑一和百里的第十名哪个更优秀,参考代码def func1(): result = 1 for i in range(10): tmp = random.random() result = min(tmp, result) return resultdef func2(): ...

2019-10-08 16:28:14 249

原创 放回、不放回的概率计算

有A,B,C…共9种不同卡片,每种卡片都有13张,每次取一张,如果是A卡片就拿走,不是就放回,求:取多少次,能让A卡片拿走大于等于3次的概率大于90%?思路考虑每一次取牌对当前状态的影响,考虑取牌分别是A和非A对当前状态的影响,构造状态转移函数,计算每一次取牌后各个状态的概率。参考代码iteration_id = 0num = 14pl = [0 for i in range(num)...

2019-10-08 15:48:28 13928

原创 随机、公平的红包分配问题解析

石头2019/7/28博弈论里面有个有趣的问题。要平分一个蛋糕给两个人,该使用怎样的方案才能使这两个人都满意。答案也很巧妙,就是另一个人先选,让切的人拿剩下的那一块,如此的话切的人就会想办法把蛋糕切得比较均匀,乃不至于自己剩下一个小的蛋糕。蛋糕分配问题,给第一个切蛋糕的人提出了一个小小的挑战,来保证公平。与之类似,现实中常见的随机红包分配算法则是一个更加有趣的算法。本文就来讨论一下公平性、随...

2019-07-28 18:35:27 1834

原创 三门问题

石头2019/7/7“没搞清楚问题之前别瞎激动系列”一、囚徒问题监狱里关了三个囚犯A、B、C。监狱长决定赦免其中一个人,并且完全随机地选择了一人作为赦免人(另外两个人将被处死)。他将自己的选择告诉了看守,但是要求看守暂时不能泄露被赦免人的姓名。囚犯A问看守“谁被赦免了”,看守拒绝回答。A接着问道:“B和C之中谁一定会被处死?”看守心想:“不论谁被赦免,B和C之中一定有一个人会被处死。因...

2019-07-07 20:32:52 1433

原创 随机桶内放球的场景分析

假设n个报文,m个队列,那么队列长度不超过k的概率是多少呢?p = A / B只需要把A,B分别计算出来就好了。代码如下:def FACT(n): m = 1 for i in range(n): m = m * (i + 1) return mdef COMB(n, m): a = FACT(n) b = FACT(m) ...

2019-07-01 21:39:22 751

原创 EularProject 102:Triangle containment

石头2019/6/19Arranged probabilityProblem 100If a box contains twenty-one coloured discs, composed of fifteen blue discs and six red discs, and two discs were taken at random, it can be seen that the...

2019-06-19 15:10:47 187

原创 EularProject 102:Triangle containment

石头2019/6/13Three distinct points are plotted at random on a Cartesian plane, for which -1000 ≤ x, y ≤ 1000, such that a triangle is formed.Consider the following two triangles:A(-340,495), B(-153,...

2019-06-13 20:20:12 275

原创 EularProject 101:Optimum polynomial

If we are presented with the first k terms of a sequence it is impossible to say with certainty the value of the next term, as there are infinitely many polynomial functions that can model the sequenc...

2018-12-22 18:58:34 369

原创 EularProject 70:Totient permutation

Euler’s Totient function, φ(n) [sometimes called the phi function], is used to determine the number of positive numbers less than or equal to n which are relatively prime to n. For example, as 1, 2, 4...

2018-05-21 21:59:56 364

原创 EularProject 87:Prime power triples

The smallest number expressible as the sum of a prime square, prime cube, and prime fourth power is 28. In fact, there are exactly four numbers below fifty that can be expressed in such a way:28 = 2...

2018-05-20 20:53:43 385

原创 素数

1、素数的密度素数分布函数π(n)素数分布函数π(n)素数分布函数\pi(n)表示小于等于n的整数中素数的个数,例如π(10)=4π(10)=4\pi(10) =4素数定理limn−&amp;amp;amp;gt;∞π(n)n/lnn=1(1)(1)limn−&amp;amp;amp;gt;∞π(n)n/ln⁡n=1\lim_{n-&amp;amp;gt;\infty}\frac{\pi(n)}{n/\ln n}=1\tag{1} 可知,随机选取一...

2018-05-13 22:47:12 591

原创 中国剩余定理(孙子定理)

中国国剩余定理,又名孙子定理,是中国古代求解一次同余式组的方法。当前可用于解决密码学中的秘密共享问题,也可以用来解决布隆过滤器的false positive问题。1. 中国剩余定理如果,有如下一元线性同余方程组(pi为素数)(pi为素数)(p_i为素数) ⎧⎩⎨⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪⎪x≡a1(modp1)x≡a2(modp2)...x≡an(modpn)(1)(1){x≡a...

2018-05-10 22:15:10 3283

原创 隐马尔科夫模型

1 基本模型模型介绍Q:" role="presentation" style="position: relative;">Q:Q:Q:所有状态集合,V" role="presentation" style="position: relative;">VVV所有观测集合 Q={q1,q2,...,qN},V={v1,v2,...,vM}" role="presentation"

2018-01-28 19:47:57 692

原创 马尔科夫决策过程

1 基本模型马尔科夫决策过程的基本模型是一个四元组&amp;amp;amp;lt;S,A,T,R&amp;amp;amp;gt;&amp;amp;quot; role=&amp;amp;quot;presentation&amp;amp;quot; style=&amp;amp;quot;position: relative;&amp;amp;quot;&amp;amp;gt;S,A,T,R&amp;amp;gt;S,A,T,R

2018-01-25 22:52:20 2579

原创 自然常数e

Andrew Zhang Nov 28, 2017自然常数ee来自于银行的复利计算。 假设银行规定不考虑复利的时候年利率是100%,也就是说你存进去100块,一年后可以拿到200块。 那么考虑复利的时候,存进去100块,一年后你能拿到多少钱呢? 可以一步一步求解,首先可以将一年平均分为n个时间段,那么一年后拿到的钱应该为 100(1+100%n)n=100(1+1n)n(1)100(1+

2017-11-28 21:51:02 2566

原创 哈希在元素包含测试中的应用

Andrew Zhang Nov 16, 2017一、d-left hashing 以2-left hashing为例,两个相同长度的hash表,T1和T2,分配对应两个hash函数,h1和h2。存储一个key时,分别用两个hash函数h1和h2计算两个位置h1[key]和h2[key],然后看看两个hash table对应位置有没有空,只要任意一个有空就可以将此key放在对应位置。 当采用

2017-11-16 23:38:25 546

原创 动态规划问题小结

Andrew Zhang Nov 11, 2017Part I 1-1、一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法 1-2、一只青蛙一次可以跳上1级台阶,也可以跳上2级……它也可以跳上n级。求该青蛙跳上一个n级的台阶总共有多少种跳法 Part II 2-1、[HihoCoder]#1038 : 01背包 2-2、[HihoCoder]#10

2017-11-12 00:07:35 397

原创 EularProject 73:Counting fractions in a range

Andrew Zhang Nov 11, 2017Consider the fraction, n/d, where n and d are positive integers. If n < d and HCF(n,d)=1, it is called a reduced proper fraction.If we list the set of reduced proper fraction

2017-11-11 19:34:38 340

原创 EularProject 85:Counting rectangles

Andrew Zhang Nov 4, 2017By counting carefully it can be seen that a rectangular grid measuring 3 by 2 contains eighteen rectangles: Although there exists no rectangular grid that contains exactly tw

2017-11-04 23:38:42 360

原创 EularProject 66:Diophantine equation

Andrew Zhang Nov 4, 2017Consider quadratic Diophantine equations of the form:x2–Dy2=1x^2 – Dy^2 = 1For example, when D=13, the minimal solution in x is 6492–13×1802=1649^2 – 13×180^2 = 1.It can be as

2017-11-04 23:31:57 391

原创 EularProject 61:Cyclical figurate numbers

Andrew Zhang Sep 4, 2017Triangle, square, pentagonal, hexagonal, heptagonal, and octagonal numbers are all figurate (polygonal) numbers and are generated by the following formulae:Triangle P3,

2017-10-17 21:22:48 436

原创 [网易]2018校园招聘编程题真题集合

Andrew Zhang Sep 16, 2017题目: 小易准备去魔法王国采购魔法神器,购买魔法神器需要使用魔法币,但是小易现在一枚魔法币都没有,但是小易有两台魔法机器可以通过投入x(x可以为0)个魔法币产生更多的魔法币。 魔法机器1:如果投入x个魔法币,魔法机器会将其变为2x+1个魔法币 魔法机器2:如果投入x个魔法币,魔法机器会将其变为2x+2个魔法币 小易采购魔法神器总共需要n个魔

2017-09-16 23:09:13 739

原创 [爱奇艺]校招笔试(2017/9/11)

Andrew Zhang Sep 11, 2017工作好闲。参加校招笔试玩玩儿,题目很简单。题目2: 如果一个数字满足以下条件,就称它是奇异数 1、这个数字至少有两位 2、这个数字的最低两位是相同的 计算区间[L,R]内的所有奇异数。参考答案:#include <iostream>using namespace std;long long func(long long v){

2017-09-11 20:39:49 911

原创 EularProject 74:Digit factorial chains

Andrew zhang Sep 4, 2017The number 145 is well known for the property that the sum of the factorial of its digits is equal to 145:1! + 4! + 5! = 1 + 24 + 120 = 145Perhaps less well known is 169, in th

2017-09-04 23:21:08 351

原创 [Algorithm] beam search(集束搜索)

华电北风吹 2017年8月6日beam search是一个普通搜索算法的优化技巧。 拿A*为例来说,在nn维平面中,一个点有3n−13^n-1个邻接点,随着n的增加,需要保存的状态点的个数指数级增加。 如果内存不支持把所有的状态点都给保存了,而还想采用A*算法那怎么办?一个选择就是可以采用beam search的思路,比如说根据适应度函数只保存一半的状态点,或者更少。当然,缺点就是beam s

2017-08-06 18:25:32 1378

转载 计算机科学中最重要的32个算法

英文原址:http://www.risc.jku.at/people/ckoutsch/stuff/e_algorithms.html奥地利符号计算研究所(Research Institute for Symbolic Computation,简称RISC)的Christoph Koutschan博士在自己的页面上发布了一篇文章,提到他做了一个调查,参与者大多数是计算机科学家,他请这些科学家投票选出

2017-08-06 17:30:00 10416

原创 EularProject 71:Ordered fractions

lazy_piger 2017-07-16Consider the fraction, n/d, where n and d are positive integers. If n<<d and HCF(n,d)=1, it is called a reduced proper fraction.If we list the set of reduced proper fractions for

2017-07-16 14:42:46 693

原创 Eularproject 76:Counting summations

Andrew Zhang Jul 16, 2017It is possible to write five as a sum in exactly six different ways:4 + 1 3 + 2 3 + 1 + 1 2 + 2 + 1 2 + 1 + 1 + 1 1 + 1 + 1 + 1 + 1How many different ways can one hundred

2017-07-16 01:02:47 598 2

原创 [HihoCoder]#1078 : 线段树的区间修改

华电北风吹 日期:2017-06-01题目链接: http://hihocoder.com/problemset/problem/1078题目分析: 目前超时,有空改改参考代码:#include <stdio.h>#include <algorithm>using namespace std;#define INT_MAX 0x7fffffffstruct node{ in

2017-06-01 23:28:00 706

原创 [Algorithm] 哈希

华电北风吹 日期:2017-05-30哈希由于其高效的时间复杂度得到了很多的应用。 一、关键字查找 这个应该是Hash最基本的应用了。相比于线查的O(n),BST的O(nlog n)的时间复杂度,Hash仅仅需要O(1)的复杂度。二、完美Hash三、信息指纹 信息指纹的提出刚开始是为了解决搜索引擎遇到的各个网页网址过长的问题,利用Hash的方法,可以将各个网址压缩到一个固定宽度

2017-05-30 21:02:30 490

原创 C语言的指针

华电北风吹 日期:2017-05-25指针,数组,二级指针,指针数组,数组指针#include <stdio.h>#include <stdlib.h>int main(){ int val; int arr1[3] = {1, 2, 3}; int arr2[2][3]= {1, 2, 3, 4, 5, 6}; int *p; int *p1[3];

2017-05-25 22:10:54 296

原创 makefile小例子

华电北风吹 2017年4月9号一、用到的三个代码 主函数代码:#include <stdio.h>#include <stdlib.h>#include "LinkList.h"int main(){ LinkList* lst=(LinkList*)malloc(sizeof(LinkList)); InsertAtHead(lst,1); InsertAtHea

2017-04-09 01:55:08 655

原创 GDB调试指令

华电北风吹 2017年4月9日gcc mainfunc.c -o mainfunc -g上面的命令行中, -o 参数指定了编译生成的可执行文件名,参数 -g 表示将源代码信息编译到可执行文件中。如果不使用参数 -g,会给后面的GDB调试造成不便。当然,如果没有程序的源代码,自然也无从使用 -g 参数,调试/跟踪时也只能是汇编代码级别的调试/跟踪。gdbgdb命令启动GDB,并显示GDB说明file

2017-04-09 00:19:24 588

转载 GCC编译过程

1 简介 GCC 的意思也只是 GNU C Compiler 而已。经过了这么多年的发展,GCC 已经不仅仅能支持 C 语言;它现在还支持 Ada 语言、C++ 语言、Java 语言、Objective C 语言、Pascal 语言、COBOL语言,以及支持函数式编程和逻辑编程的 Mercury 语言,等等。而 GCC 也不再单只是 GNU C 语言编译器的意思了,而是变成了 GNU Compil

2017-04-09 00:02:29 906

转载 内存,磁盘,cache等访问速度

google 工程师Jeff Dean 首先在他关于分布式系统的ppt文档列出来的,到处被引用的很多。1纳秒等于10亿分之一秒,= 10 ^ -9 秒 Numbers Everyone Should Know L1 cache reference 读取CPU的一级缓存 0.5 ns Branch mispredict(转移、分支预测) 5 ns L2 cache reference 读取

2017-04-05 22:49:28 1050

原创 Floyd-Warshall算法python代码

华电北风吹 2017年3月12日未连接的边需要赋一个初始值,可以把矩阵所有元素值相加再加1。附加功能是计算最短路径的条数。import sysdef Floyd(Graph,ShortestPath,PathCount): NodeNum=len(Graph) lastShortestDistance=[[0 for i in range(NodeNum)] for j in ran

2017-03-12 22:05:22 2839 1

nature 非负矩阵分解 1999

2016-05-02

matlab 2013b的visual studio 2013配置文件

帮助matlab 2013找到visual studio 2013编译环境

2015-11-19

基于SVM的AdaBoost

论文将怎么使用SVM构建强分类器,讲的特别好,中间还有讲解RBF-SVM参数的意义。

2015-11-13

斯坦福的凸优化教材

Convex Optimization Stephen Boyd Department of Electrical Engineering Stanford University Lieven Vandenberghe Electrical Engineering Department University of California, Los Angeles

2015-10-24

SPSS学习在统计分析中的应用

SPSS虽然功能不如SAS强大,但是界面化了以后简单易学

2014-10-23

SVM学习教程(自己学习时候看的PDF)

学习SVM时候找了很多资料最终选择的这个PDF一看就懂了

2014-10-23

数学建模试题

数学建模今年试题,更有利于为今年准备。。。。。。。。希望你获得更好成绩

2011-11-18

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除