离散数学入门级概念:集合、关系、元组

前言:对于博客中提出的问题的解答

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

答:
根据集合的定义可以知道,上述的集合有四个元素,分别是 0 , 1 , { 0 , 1 } , { 1 , 2 } 0,1,\{0,1\},\{1,2\} 01{0,1}{1,2}
在看到这类形式的数据的时候,我的第一想法就是广义表。
关于在机器学习中的优缺点,目前而来还没有比较深刻的体会。这次就对数据结构层次的优缺点进行表述,优点:可以便利的进行便利;缺点:在查找的时候遍历深度可以会很高。
了解到了单标签学习和多标签学习的定义之后,优点:对于多标签学习来说,这类形式的集合天然支持多标签学习的输出。
缺点:在解析数据的时候,数据深度可能过高导致程序执行效率降低。

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

前置知识:集合 A \mathbf{A} A的基数(cardinality),表示为 ∣ A ∣ |\mathbf{A}| A,指集合 A \mathbf{A} A中元素的个数
答:

∅ \varnothing 表示空集,其中元素个数为零,基数是0; { ∅ } \{\varnothing\} {}表示包含一个空集元素的集合,元素个数为一,基数是1。

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

前置知识:Traditional single-label classification is concerned with learning from a set of examples that are associated with a single label l from a set of disjoint labels L, |L| > 1. In multi-label classification, the examples are associated with a set of labels Y in L.(直白的理解就是识别一幅画(有太阳和沙滩)中的内容,单标签学习只会输出一个标签如太阳或者沙滩,而多标签学习会输出太阳和沙滩)

答:
函数三要素:定义域A、值域C和对应法则f(映射)。定义域与值域是存在且合理的,只需要考虑映射是否符合函数定义,对于输入的数据,在值域中存在唯一的元素与之对应。所以多标签学习中, 输出为一个向量,相应的学习器算函数。

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

答:

/**
 * 定义一个二元组
 */
public class Tuple {
    //权重
    private int weight;

    //一组盒子
    private Set<Box> boxSet;

    public Tuple(Set<Box> boxSet) {
        this.boxSet = boxSet;
        //随机赋权重
        int i = new Random().nextInt();
        this.weight = Math.abs(i) % 10;
    }

    @Override
    public String toString() {
        return "Tuple{" +
                "weight=" + weight +
                ", boxSet=" + boxSet +
                '}';
    }
    private static class Box {
        //标号,唯一确定一个盒子
        private String mark;
        //填充物类型
        private String dataType;
        //容量
        private int capacity;

        public Box(String dataType) {
            this.mark = this.hashCode()+"";
            this.dataType = dataType;
            Random random = new Random();
            this.capacity = Math.abs(random.nextInt());
        }

        @Override
        public String toString() {
            return "Box{" +
                    "mark='" + mark + '\'' +
                    ", dataType='" + dataType + '\'' +
                    ", capacity=" + capacity +
                    '}';
        }
    }

    public static void main(String[] args) {
        Set<Box> boxSet = new HashSet<>();
        Box box1 = new Box("uint8");
        Box box2 = new Box("string");
        boxSet.add(box1);
        boxSet.add(box2);
        Tuple tuple = new Tuple(boxSet);
        //通过调用元组的toString方法,元素重载的toString也得以调用
        //st.元组也表达了对象的函数部分
        System.out.println(tuple.toString());
    }
}

输出:

Tuple{weight=8, boxSet=[Box{mark='621009875', dataType='uint8', capacity=1809725570}, Box{mark='2125039532', dataType='string', 	capacity=464452496}]}

习题 7: 定义二叉树.

答:
Let Σ = { l , r } \Sigma = \{\mathrm{l}, \mathrm{r}\} Σ={l,r}be the alphbet and ϕ \phi ϕ be a null node. A binary tree is a triple T = ( V , r , c ) T = (\bm{V}, r, c) T=(V,r,c), where V = { v 1 , … , v n } \bm{V} = \{v_1, \dots, v_n\} V={v1,,vn}is the set of nodes, r ∈ V r \in \bm{V} rVis the root, and c : V ∪ { ϕ } × Σ + → V ∪ { ϕ } c:\bm{V} \cup \{\phi\} \times \Sigma^+ \to \bm{V} \cup \{\phi\} c:V{ϕ}×Σ+V{ϕ} satisfying
a) c ( ϕ , l ) = c ( ϕ , r ) = ϕ c(\phi, \mathrm{l}) = c(\phi, \mathrm{r}) = \phi c(ϕ,l)=c(ϕ,r)=ϕ;
b) ∀ v ∈ V ∖ { r } \forall v \in \bm{V} \setminus \{r\} vV{r}, ∃ \exists 1 s ∈ Σ + \in \Sigma^+ Σ+ st. c ( r , s ) = v c ( r , s ) = v c(r,s)=v;
c) ∀ v ∈ V \forall v \in \bm{V} vV, ! ∃ s ∈ Σ + ! \exists s \in \Sigma^+ !sΣ+ st. c ( v , s ) = v c ( v , s ) = v c(v,s)=v

Let Σ = { l , r } \Sigma = \{\mathrm{l}, \mathrm{r}\} Σ={l,r}be the alphbet and ϕ \phi ϕ be a null node. A binary tree is a triple T = ( V , r , c ) T = (\bm{V}, r, c) T=(V,r,c), where V = { v 1 , … , v n } \bm{V} = \{v_1, \dots, v_n\} V={v1,,vn}is the set of nodes, r ∈ V r \in \bm{V} rVis the root, and c : V ∪ { ϕ } × Σ ∗ → V ∪ { ϕ } c:\bm{V} \cup \{\phi\} \times \Sigma^* \to \bm{V} \cup \{\phi\} c:V{ϕ}×ΣV{ϕ} satisfying
∀ v ∈ V \forall v \in \bm{V} vV, ∃ 1 s ∈ Σ ∗ \exists1s\in \Sigma^* 1sΣ st. c ( r , s ) = v c ( r , s ) = v c(r,s)=v;

question:
a) c是一个关系,我现在的理解是c只能从根节点往下至叶子节点跳转,因为字符串闭包只包含左( l l l)和右( r r r),没有从子节点到父节点的跳 转,所以说上述的第三个条件无法证明是否有环。

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

Definition 10. A weighted undirected graph is a tuple G w = ( V , w ) G_w = (\bm{V}, w) Gw=(V,w), where V = { v 1 , … , v n } \bm{V} = \{v_1, \dots, v_n\} V={v1,,vn} is the set of nodes, and w : V × V → R + ∪ { 0 } w:\bm{V} \times \bm{V} \to \mathbb{R}^+ \cup \{0\} w:V×VR+{0} is the edge weight function and w ( v i , v j ) = w ( v j , v i ) w(v_i,v_j) = w(v_j,v_i) w(vi,vj)=w(vj,vi)

和带权有向图之间的区别就是,节点之间的权值相等

习题 9. 考虑 ϕ \phi ϕ, 重新写 Definition 7 以解决其存在的问题, 见其讨论 d).

Definition 7. A tree is a triple T = ( V , r , p ) T = (\bm{V}, r, p) T=(V,r,p), where V = { v 1 , … , v n } \bm{V} = \{v_1, \dots, v_n\} V={v1,,vn} is the set of nodes, r ∈ V r \in \bm{V} rV is the root, and p: V ∪ { ϕ } ∖ { r } → V ∪ { ϕ } \bm{V}\cup\{\phi\} \setminus \{r\} \to \bm{V}\cup\{\phi\} V{ϕ}{r}V{ϕ} is the parent function satisfying
a) ∀ k ≥ 1 \forall k \geq 1 k1, p k ( v ) ≠ v p^k(v) \neq v pk(v)=v, and
b) ∀ v ∈ V ∖ { r } \forall v \in \bm{V}\setminus\{r\} vV{r}, ∃ \exists 1 k ≥ 1 k\geq1 k1, st. p k ( v ) = r p^k(v) = r pk(v)=r
c)if v = { ϕ } v=\{\phi\} v={ϕ}, ∀ k ≥ 1 \forall k\geq1 k1, st. p k ( v ) = { ϕ } p^k(v)=\{\phi\} pk(v)={ϕ}

question:
1.p函数的输出输出类型应该是集合,如果不是集合,那p函数的递归调用就存在着问题
2.如果question1存在,那么b)中的 ∀ v ∈ V \forall v\in\bm{V} vV 应该怎么改

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

答:
A binary tree is a 5-tuple M = ( Σ , Q , q 0 , T , f ) M = (\Sigma, \bm{Q}, \bm{q}_0, \bm{T}, f) M=(Σ,Q,q0,T,f), where
a) Σ \Sigma Σ is the alphabet { l , r } \{l,r\} {l,r};
b) Q \bm{Q} Q is the set of states V ∪ { ϕ } \bm{V}\cup\{\phi\} V{ϕ},V is the set of nodes, ϕ \phi ϕ is the null node;
c) q 0 ∈ V \bm{q}_0 \in \bm{V} q0V is the root node;
d) T ∈ Q \bm{T} \in \bm{Q} TQ is the set of terminal state ϕ \phi ϕ ;
e) f : Q × Σ ∗ → Q f:\bm{Q} \times \Sigma^* \to \bm{Q} f:Q×ΣQ is the transition function.
Any s ∈ Σ ∗ s \in \Sigma^* sΣ is accepted by the automata iff f ( q 0 , s ) ∈ T f(\bm{q}_0, s) \in \bm{T} f(q0,s)T satisfying
1) ∀ k ≥ 1 \forall k \geq 1 k1, f k ( q 0 ) ≠ q 0 f^k(\bm{q}_0) \neq \bm{q}_0 fk(q0)=q0, and
2) ∀ v ∈ Q ∖ { q 0 , ϕ } \forall v \in \bm{\bm{Q}}\setminus\{\bm{q}_0,\phi\} vQ{q0,ϕ}, ∃ \exists 1 k ≥ 1 k\geq1 k1, st. f k ( v ) = r f^k(v) = r fk(v)=r,and
3) i f   v = { ϕ } if\,v=\{\phi\} ifv={ϕ}, ∀ k ≥ 1 \forall k\geq1 k1, st. p k ( v ) = { ϕ } p^k(v)=\{\phi\} pk(v)={ϕ}

1) ∀ v ∈ V , ∃ 1 s ∈ Σ ∗ , s t . f ( q 0 , s ) = v \forall v \in \bm{V},\exist1s\in\Sigma^*,st.f(q_0,s)=v vV,1sΣ,st.f(q0,s)=v

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

答:
A tree is a 5-tuple M = ( Σ , Q , q 0 , T , f ) M = (\Sigma, \bm{Q}, \bm{q}_0, \bm{T}, f) M=(Σ,Q,q0,T,f), where
a) Σ \Sigma Σ is the alphabet { c , b } \{\mathrm{c},\mathrm{b}\} {c,b}, c \mathrm{c} c present the children node of the current node, b \mathrm{b} b present the next brother node of the current node;
b) Q \bm{Q} Q is the set of states V ∪ { ϕ } \bm{V}\cup\{\phi\} V{ϕ},V is the set of nodes, ϕ \phi ϕ is the null node;
c) q 0 ∈ V \bm{q}_0 \in \bm{V} q0V is the root node;
d) T = { ϕ } \bm{T} =\{\phi\} T={ϕ} is the set of terminal states ;
e) f : Q × Σ ∗ → Q f:\bm{Q} \times \Sigma^* \to \bm{Q} f:Q×ΣQ is the transition function.
Any s ∈ Σ ∗ s \in \Sigma^* sΣ is accepted by the automata iff f ( q 0 , s ) ∈ T f(\bm{q}_0, s) \in \bm{T} f(q0,s)T satisfying
∀ v ∈ V , ∃ 1 s ∈ Σ ∗ , s t . f ( q 0 , s ) = v \forall v \in \bm{V},\exist1s\in\Sigma^*,st.f(q_0,s)=v vV,1sΣ,st.f(q0,s)=v

随笔

1.集合悖论
2.广义表
⟨ X , Y ⟩ \langle X,Y \rangle X,Y
3.数据集矩阵表示法转置的必要性
D = ( x 1 , x 2 , … , x n ) T , x i ∈ R m \mathbf{D}=(x_1,x_2,…,x_n)^\mathrm{T},x_i\in\Bbb{R}^m D=(x1,x2,,xn)T,xiRm,不添加转置符号代表着一个只有一行的矩阵,和我们预想的mxn的矩阵相差甚远
4.函数的理解,定义域,值域,定义域与值域之间的映射,映射是定义域中的任意元素,在值域中有唯一的元素与之对应。

5.关系:在数学中, f ( x , y , z ) = 0 f(x,y,z)=0 f(x,y,z)=0是一个三元的表达式,唯一确认了关于想x,y,z之间的三元关系,同时也可以表示为 { Y } \{\mathbf{Y}\} {Y} { X , Z } \{\mathbf{X},\mathbf{Z}\} {X,Z}之间的映射 y = g ( x , z ) y=g(x,z) y=g(x,z),至于这个映射是不是函数关系,需要判断是否 ∀ x i ∈ X , ∃ 1 ( x i , z i ) ∈ ( X , Z ) \forall x_i\in\mathbf{X},\quad\exists1(x_i,z_i)\in(\mathbf{X},\mathbf{Z}) xiX,1(xi,zi)(X,Z)
6.闭包

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

来日可期1314

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值