常用的函数图像

import matplotlib.pyplot as plt
import math
import numpy as np



def calconvex(X):
    demational = X.shape[1]
    Xtemp = np.zeros(shape=(demational, demational))
    mean = np.mean(X, axis=0)
    for i in range(len(X)):
        reduce = [X[i, :] - mean]
        Xtemp = Xtemp + np.dot(np.transpose(reduce), reduce)

    convex = 1 / len(X) * (Xtemp)
    return convex

plt.figure(figsize=(8, 8))
plt.subplots_adjust(bottom=.05, top=.9, left=.05, right=.95)

plt.subplot(111)

num = 100

# X1, Y1= make_gaussian_quantiles(cov=100,n_features=2, n_classes=1,n_samples=num)
# # plt.scatter(X1[:, 0], X1[:, 1], marker='o')
x1 = np.linspace(0,10,50)
# y1 = np.power(math.e,1.0/x1)
y1 = 1.0 / x1
plt.plot(x1,y1,label="1/x")
# plt.title("convex : %d" % np.sum(calconvex(X1)), fontsize='small')
# x2 = np.linspace(0,10,20)
y2 = np.log(x1)
plt.plot(x1,y2,label="ln")


y3 = x1
plt.plot(x1,y3,label="x")

y4 = np.sqrt(x1)
plt.plot(x1,y4,label="sqrtx")


y5 = np.exp(x1)
plt.plot(x1,y5,label="e")

y6 = np.power(x1,2)
plt.plot(x1,y6,label="x^2")
plt.grid()
plt.legend()

plt.axis([0,10,0,10])
plt.savefig("image/test.png")
plt.show()

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值