离散数学入门1

这篇博客介绍了离散数学的基础概念,包括集合的定义、基数、笛卡尔积和幂集。此外,还讨论了二元关系、函数的性质,以及元组在数据表示中的应用。通过对集合理论的理解,有助于深化对机器学习中多标签学习和数据结构的认识。

1.集合

1.1 集合的定义

集合:是由指定范围内的满足给定条件的所有对象聚集在一起构成,每一个对象称为这个集合的元素。

例如:

A={1,2,3,4},描述了由1,2,3,4四个元素构成的集合A。

· 其中集合与元素的顺序无关。

· 集合中的元素是互异的,若一个集合中有多个相同元素则只能算作一个。

习题 1: { 0 , 1 , { 0 , 1 } , { 1 , 2 } }有几个元素? 机器学习中, 这类形式的集合有什么优点和缺点?

集合中各个元素通过逗号分隔,由此可见上题集合中有四个元素。

优点:有利于多标签学习

缺点:因其集合中的元素类别等不同,处理时会复杂一些。

1.2 基数

集合A中元素的个数,就是集合的基数,也称为集合的势,记作|A|。

习题 2: ∅ 的基数是多少? { ∅ }呢?

  ∅表示空集,即基数为零;{ ∅ }表示此集合中只有 ∅一个基数。

1.3 笛卡尔积

· 有序对:有两个元素x和y按一定顺序排列成的二元组叫做有序对或有序偶,记作<x,y>。称x,y分别为序偶的第一,第二元素。

· 笛卡尔积:设A,B为集合,用A中元素为第一元素,B中元素为第二元素构成有序对。所有这样的有序对组成的集合叫做A和B的笛卡尔积,记作AxB,表示为AxB={<x,y>|x∈A^y∈B}。

· 定理 :若A,B都是有限集,且|A|=m,|B|=n,则|AxB|=|A|x|B|=mxn。

· 性质 :笛卡尔积不满足交换律和结合律,对并和交运算满足分配率。

· 关系的表示 :

  三种方式:列举法,矩阵法,关系图法。

1.4 幂集

Definition 2. The power set of Ais given by
                                            2^{A}= { B ∣ B ⊆ A } . 

所谓幂集,就是原集合A中所有的子集(包括全集和空集)构成的集族。

例:A={1,2,3}, 2 ^A ={∅, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}.

2. 二元关系

Definition 3. Let A and B be two sets. Any R ⊆ A × B is a binray relation.

3. 函数 

Definition 4. Let V 1 , … , V m be the domain of conditional attribute a 1 , … , am, respectively, and L  be the set of classes. A classifier is a function f : V 1 × ⋯ × V m → L .

 ·函数是特殊的关系,它满足:

         函数的定义域是domf=X,而不能是domf的某个真子集。
         若<x,y>∈f,<x,y'>∈f,则y=y'(单值性)

·特别的:对空关系∅⊆AxB,

         如果A=∅,空关系∅是函数

         如果A≠∅,空关系∅不是函数

习题5:多标签学习中,输出为一个向量,相应的学习器算不算函数呢?

首先回答是肯定的。输入一个数据,通过映射得到相应的输出数据,虽然输出为一个向量,但是在机器学习里,其本身就是寻找一个个函数,通过函数和输入得到输出,所以相应的学习器算是一个函数。

4.元组

元组(tuple)是关系数据库中的基本概念,关系是一张表,表中的每行(即数据库中的每条记录)就是一个元组,每列就是一个属性,

其中图是最经典的元组,下面分别是有向图、无向图以及带权图的定义

Definition 5. A directed graph is a tuple G_{d} = ( V , E ), where V = { v_{1}, … , v_{n}}is the set of nodes, and E ⊆ V × V is the set of edges,

Definition 6. An undirected graph is a tupleG_{u} = ( V , E ) , where V = { v_{1}, … , v_{n}}is the set of nodes, E ⊆ V × V is the set of edges, and 〈 v i , v j 〉 ∈ E iff 〈 v j , v i 〉 ∈ E .

 Definition 7. A weighted directed graph is a tuple G_{w} = ( V , w ), where V = { v_{1} , … , v_{n}}  is the set of nodes, and w : V × V → \mathbb{R}^{+}∪ { 0 } is the edge weight function.

 习题6:元组只能表达对象的数据部分, 还是可以完整地表达 (既包括数据, 也包括方法/函数)? 用一个具体的程序来说明.

答案是可以完整表达。列子如下:

tup1 = ('computer', 'math', 11, 12)
tup2 = (1, 2)
tup3 = ('cm',tup1,tup2)
print("tup3: ",tup3)
print("tup1[0]: ", tup1[0])

 

tup3:  ('cm', ('computer', 'math', 11, 12), (1, 2))
tup1[0]:  computer
[Finished in 0.1s]

习题 7: 定义二叉树.

Let \Sigma =\left \{ l,r \right \} be the alphbet and \varnothing be a null node.Abinary tree is a triple T=\left ( V,r,c \right ),where V=\left \{ v_{1,...,v_{2}} \right \} is the set of nodes,r\in V is the root,and c:V\cup \left \{ \O \right \}\times \Sigma ^{+}\rightarrow V\cup \left \{ \O \right \} satisfying

a)\forall v\in V,!\exists \in \Sigma ^{+}st.c(v,s)=v;

b)\forall v\in V\setminus \left \{ r \right \}iffr\neq \left \{ \O \right \},\exists ls\in \Sigma ^{+}st.c(r,s)=v

习题 8: 定义带权无向图.

A weigheed undirected graph is a tuple G_{w}=(V,w),where V=\left \{ v_{1},...v_{n} \right \} is the set of nodes,and w:V\times V\rightarrow \mathbb{R^{+}}\cup \left \{ 0 \right \} is theedge weight function satisfying w\left ( v_{i} ,v_{j}\right )=w\left ( v_{j} ,v_{i}\right )
 

习题9:重新考虑\O,重新写Definition6 以解决其存在的问题,捡起讨论d) 

A tree is a triple T= \left ( V,r,p \right ) and ∅ be a null node,where V=\left \{ v_{1},...v_{n} \right \} is the set of nodes,r∈V is the root,and p:V\setminus \left \{ r \right \}\rightarrow V is the parent function satisfying 

a)\forall k\geq 1,p^{k}\left ( v \right )\neq v,p^{k}\left ( r \right )= \O ,p\left ( r \right )=\O

b)\forall v\in V\setminus \left \{ r \right \},\exists 1k\geq 1,st.p^{k}\left ( v \right )=r

确定的有穷状态的自动机定义如下:

A deterministic finite state automata (DFA) is a 5-tuple M=\left ( \Sigma ,Q,q_{0} ,T,f\right ),where

a)\Sigma is the alphabet;

b)Q is the set of states;

c)q_{0}\in Qis the start state;

d)T\subseteq Q is the set of the terminal states;

e)f:Q\times \Sigma ^{*}\rightarrow Q is the transition function.

Any s\in \Sigma ^{*} is accepted by automata iff f\left ( q_{0},s \right )\in T

习题 3.1 模仿自动机的样子来重新定义二叉树.

A binary tree is a 5-tuple M= \left ( \Sigma ,Q,r,\o ,f \right ),where

a)\Sigma is the alphabet;

b)Q=V\cup \o is the set of states,where V is the set of node and ∅ isthe null node;

c)r\in Q\cup \left \{ \o \right \} is the root or start state;

d)\o \subseteq Q is the set of terminal state;

e)f:Q\times \Sigma ^{*}\rightarrow Q is the transition function.

Any s\in \Sigma ^{*} is accepted by automata iff f\left ( r,s \right )\in Q\setminus \left \{ \o \right \}

习题3.2 模仿自动机的样子来重新定义树. 

A tree is a 5-tuple M=\left ( \Sigma ,V,r,p,f \right ),where

a)\Sigma is the alphabet;

b)V is the set of nodes;

c)r\in V is the root;

d)p is the parent;

e)f:V\times \Sigma ^{*}\rightarrow V is the transition function.

Any s\in \Sigma ^{*} is accepted by automata iff f\left ( r,s \right )\in V\

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值