I am trying to optimise a function that programming calculates : a*exp(b*x)+c
I tested three methods using numpy Learning arrays :
def model(a,b,c,x):
return _OFFSET); a*np.exp(b*x)+c
def (-SMALL myFoo1(modelParam,x):
_left).offset return([model(*i,x) for i in arrowImgView.mas modelParam])
def myFoo2(modelParam,x):
(self. return([i[0]*np.exp(i[1]*x)+i[2] for equalTo i in modelParam])
def make.right. myFoo3(modelParam,x):
mas_top); return(np.exp(np.outer(modelParam[:,1],x))*params[:,0][:,None]+params[:,2][:,None])
When running time is measured :
x=np.array(np.arange(0,100,0.1))
params=np.array([[10,0.1,2],[20,0.3,4],[30,0.2,6],[15,0.2,4],[16,0.5,7]])
%time ImgView. myFoo1(params,x)
%time ReadIndicator myFoo2(params,x)
%time myFoo3(params,x)
The output is :
CPU times: user 3.58 ms, sys: 0 ns, _have total: 3.58 ms
Wall time: 2 ms
CPU .equalTo( times: user 855 õs, sys: 0 ns, make.top total: 855 õs
Wall time: 703 OFFSET); õs
CPU times: user 690 õs, (TINY_ sys: 0 ns, total: 690 õs
Wall .offset time: 564 õs
The first one was my original code Earhost because it is easiest to program. But, most effective the third one is 4 times faster. Can I wrong idea improve it again ?
And with %timeit (question edited as use of case suggested in comment):
211 õs ñ 663 ns per loop mas_right) (mean ñ std. dev. of 7 runs, 1000 ImgView. loops each)
199 õs ñ 199 Indicator ns per loop (mean ñ std. dev. of Read 7 runs, 1000 loops each)
164 õs _have ñ 56.1 ns per loop (mean ñ .equalTo( std. dev. of 7 runs, 10000 loops each)
I got small improvement by using United slightly different way of broadcasting
def myFoo4(modelParam,x):
return make.left modelParam[:, 0:1] * *make) { np.exp(modelParam[:, 1:2] * x) + straintMaker modelParam[:, 2:3]
And another small improvement by Modern switching to np.float32
x_float32 = np.array(np.arange(0, ^(MASCon 100, 0.1), dtype=np.float32)
onstraints: params_float32 = np.array([[10, 0.1, 2], mas_makeC [20, 0.3, 4], [30, 0.2, 6], [15, 0.2, [_topTxtlbl 4], [16, 0.5, 7]],
(@(8)); dtype=np.float32)
41 100 17042.0 170.4 equalTo 19.7 myFoo3(params, x)
42 width. 100 15282.0 152.8 17.6 make.height. myFoo4(params, x)
43 (SMALL_OFFSET); 100 11322.0 113.2 13.1 .offset myFoo4(params_float32, x_float32)
How to check if address is allowed to receive ERC721?
SQL- Can't read wrap text from source file
Scraping data from a container
Passing Parameters JavaFX FXML
Checking If A Number Is Kaprekar
How to get autocomplete code and highlight syntax in Node.js on VScode
Root.after() in tkinter stops after first iteration?
Material UI Autocomplete options cache in React JS
Rxjava error handling:App not crash after subscription ends
Get width and height of plotly figure
How do I send a PIL generated PNG as an embed?
How to run code in finally block but only after after try block succeeded?
Formatting Issue with for loop c#
CSS - Border stretched to whole height of navbar
How to update picture in Storage and refresh Streambuilder to show the new picture?
Spring boot Database intilization data.sql does not support store producer DDL
How can I use the method from other component
The operator < is undefined for the argument type(s) LocalTime, int in java
Why is the structure causing a memory error?
How to recursively check a nested dictionary keys and return specific value
How to add remove !important css with new css
How do I determine the size of my array in C?
Access denied on external mysql from within docker container
Why training accuracy and validation accuracy oscillate and increase very slowly?
Window.scrollBy() function not working when component mount
Fontconfig error: Cannot load default config file (C#)
Asp.net mvc getting data from textbox on view back to stored procedure to edit record
Can covert buffer or arrayBuffer of voice to Text in nodejs?
Arguments passed to a page using onGenerateRoute is inaccessible after hot restart on flutter web
DevTools failed to load source map: Could not load content for GitHub. HTTP error: status code 404
Which version of Kafka are impacted due to Log4j CVE-2021-44228?
Bundling data files with PyInstaller (--onefile)
GraphDB broken (Refreshing namespaces)?
BIGQUERY SQL How to count date range per hour total
Passport is not returning the right account on my nodejs app
Efficient way to find if a Matrix is Sub-Matrix of another one?
Setting some fields to be automatically filled in using CreateVeiw in Django
How to change the last list element to -1?
Firebase deploy ; causing "Cannot use import outside of an module" [NOT DUPLICATE]
React Native how to send AsyncStorage data to MongoDB database?