我是靠谱客的博主 重要皮带,这篇文章主要介绍Latex 绘制函数图像前言使用到的包:示例代码:示例代码:运行结果:,现在分享给大家,希望可以做个参考。

前言

又是关于机器学习那本书里的插图问题,里面有一些函数图形。现在看看怎么使用latex把它们画出来。
这就是《机器学习》周志华,第98页的两个函数图像,貌似树上的坐标轴是不正确的,第二张图的横坐标应该扩大10倍,才有那种效果。

使用到的包:

复制代码
1
usepackage{tikz}

示例代码:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
documentclass[11pt,UTF8]{ctexart} usepackage{tikz} begin{document} begin{figure} begin{tikzpicture} draw[->](-1.2,0)--(1.2,0)node[left,below,font=tiny]{$x$}; draw[->](0,-0.2)--(0,1.2)node[right,font=tiny]{$y$}; foreach x in {-1,0,1}{draw(x,0)--(x,0.05)node[below,outer sep=2pt,font=tiny]at(x,0){x};} foreach y in {1}{draw(0,y)--(0.05,y)node[left,outer sep=2pt,font=tiny]at(0,y){y};} draw[color=red, thick,smooth,domain=0:1]plot(x,1); draw[color=red, thick,smooth,domain=-1:-0.02]plot(x,0); draw[color=red,smooth]circle(0.02); end{tikzpicture} end{figure} end{document}

运行结果:
这里写图片描述
表达式:

sgn(x)={1,x0;0,x<0;

示例代码:

复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
documentclass[landscape, 12pt]{ctexart} usepackage{tikz} begin{document} begin{figure} begin{tikzpicture} draw[->](-1.2,0)--(1.2,0)node[left,below,font=tiny]{$x$}; draw[->](0,-0.2)--(0,1.2)node[right,font=tiny]{$y$}; draw[dashed](-1.2,1)--(1.2,1); foreach x in {-1,-0.5,0,0.5,1}{draw(x,0)--(x,0.05)node[below,outer sep=2pt,font=tiny]at(x,0){x};} foreach y in {0.5,1}{draw(0,y)--(0.05,y)node[left,outer sep=2pt,font=tiny]at(0,y){y};} draw[color=red ,domain=-1.2:1.2]plot(x,{1/(1+(e^(-1*(x))))}); end{tikzpicture} end{figure} end{document}

运行结果:

这里写图片描述
表达是

sigmoid(x)=11+ex

最后

以上就是重要皮带最近收集整理的关于Latex 绘制函数图像前言使用到的包:示例代码:示例代码:运行结果:的全部内容,更多相关Latex内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(79)

评论列表共有 0 条评论

立即
投稿
返回
顶部