摘要: In practice, we estimate conditional probabilites P(A|B) = n/N, where n is the number of times A and B in common, N is the number of times B in the trainning data.what about n are very little, even equal to 0. Or n are very large, even equal to N. What's more, sometimes the values of probablitie 阅读全文
posted @ 2013-12-28 11:38 joythink89 阅读(424) 评论(0) 推荐(0) 编辑
摘要: 循环不变式(loop invariant):关于程序状态的断言(assertion),在每次循环迭代之前和之后都正确(循环执行过程中不一定为真)。在循环中分为以下三个阶段:1、初始化:循环初次执行的时候不变式为真。2、保持:如果在某处迭代开始的时候不变式为真,那么循环体执行完毕的时候仍然为真。3、终止:循环退出的时候不变式为真。利用数学归纳法知,1和2成立之后,3必然成立。选择控制结构:在程序运行过程中,多个分支中的一个被执行,之前的断言以及分支的条件可以推倒出下一个断言。迭代控制结构:在保证了循环不变式的条件下,还要满足的一个条件是:循环的终止!(二分查找的终止原因是,可能性范围在不断缩小直 阅读全文
posted @ 2013-12-06 09:19 joythink89 阅读(286) 评论(0) 推荐(0) 编辑
摘要: normrnd(mu, sigma, m,n) 返回m x n的随机数,正态分布均值mu,标准差sigma。mvnrnd(mu, sigma, m) 返回m个随机数(点),是多元正太分布,mu是均值向量,sigma是协方差。x = normrnd(0,4,1,100000); %这里是标准差,即方差的均方根。[a b] = hist(x);bar(b,a/sum(a));mu = [2 3];sigma = [1 1.5; 1.5 3]; %这里是协方差r = mvnrnd(mu,sigma,1000); 阅读全文
posted @ 2013-12-02 19:23 joythink89 阅读(1419) 评论(0) 推荐(0) 编辑
摘要: 收获:1、程序调试一定要根据结果推理,不能乱试,至少要有根据的试 2、单向链表遍历的时候要注意: 不能找到之前的元素。这样,在遍历到list末尾的时候,就不能给list添加元素了。Problem: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a li... 阅读全文
posted @ 2013-11-16 20:14 joythink89 阅读(346) 评论(0) 推荐(1) 编辑
摘要: int main(int argc, char* argv[]) 这个写法实际上是 int main(int argc, char** argv)。在函数的参数不可能是数组,所以 char* argv[],这个以指向字符的指针为元素的数组,其实转换成了指向指针的指针。所以在函数里面可以有++argv这种改变argv值的语句。数组与指针的唯一区别就是,数组是一个const 指针。所以在函数里面数组是不能++的。 阅读全文
posted @ 2013-08-07 18:15 joythink89 阅读(227) 评论(0) 推荐(0) 编辑
摘要: DLL可以理解为具有一定功能的可以嵌入到可执行程序中的程序片段。与lib文件一样,DLL在VS中可以有两种编译方式:C编译、C++编译。个人感觉动态加载DLL文件,使用DLL内部函数的时候倒都是一样的。一、C编译方式。 A:dll的生成 1 //File of "sub.h" 2 #ifndef SUB_H 3 #define SUB_H 4 extern "C" int __declspec(dllexport)sub(int x, int y); 5 #endif 6 7 //File of "sub.cpp" 8 #includ 阅读全文
posted @ 2013-07-27 10:25 joythink89 阅读(438) 评论(0) 推荐(0) 编辑
摘要: lib文件,工程知识 阅读全文
posted @ 2013-07-25 07:50 joythink89 阅读(2059) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 #include 3 #include 4 class Folder; 5 class Message; 6 7 class Folder 8 { 9 public: 10 void delete_mess(Message* pmess) 11 { 12 messages.erase(pmess); 13 } 14 void add_mess(Message* pmess) 15 { 16 messages.insert(pmess); 17 } 18 ... 阅读全文
posted @ 2013-06-28 16:18 joythink89 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 1 // set::begin/end 2 #include 3 #include 4 5 int main () 6 { 7 int myints[] = {75,23,55}; 8 std::set myset (myints,myints+2); 9 10 std::cout ::iterator it=myset.begin(); it!=myset.end();)12 {13 std::cout ::iterator it=myset.begin(); it!=myset.end();)17 {18 st... 阅读全文
posted @ 2013-06-28 16:06 joythink89 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 std::istream& fun(std::istream& is) 3 { 4 while(!is.eof()) 5 std::cout << is; 6 is.clear(); 7 return is; 8 } 9 10 11 int main()12 {13 fun(std::cin);14 return 0;15 }while()就没出去,一直有输出啊? 阅读全文
posted @ 2013-06-27 07:59 joythink89 阅读(116) 评论(0) 推荐(0) 编辑