简体   繁体   English

求函数的最大值和平均值

[英]Finding the maximum and average value of a function

I want to find the maximum value of a defined function, f(x), in the given range [a,z]. 我想在给定范围[a,z]中找到已定义函数f(x)的最大值。 a < z. a <z。 there will be n+1 samples (n is inputted in the function) that are equal in size. 将有大小相等的n + 1个样本(在函数中输入了n个)。 I also want to find the average value of f(x), with the same conditions. 我还想在相同条件下找到f(x)的平均值。 How should I go about beginning to solve this? 我应该如何开始解决这个问题?

Try this: 尝试这个:

maximum = max(map(lambda x: -f(x), my_list)  //or
maximum = max(x, key=lambda l: -f(l))


average = sum(my_list)/len(my_list)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM