exponential

Element wise exp() of scipy sparse matrix

被刻印的时光 ゝ 提交于 2019-12-12 16:27:31
问题 I have a very big sparse csc_matrix x . I want to do elementwise exp() on it. Basically what I want is to get the same result as I would have got with numpy.exp(x.toarray()) . But I can't do that(my memory won't allow me to convert the sparse matrix into an array). Is there any way out? Thanks in advance! 回答1: If you don't have the memory to hold x.toarray() , you don't have the memory to hold the output you're asking for. The output won't be sparse; in fact, unless your input has negative

PHP outputting numbers in exponential form

你说的曾经没有我的故事 提交于 2019-12-12 12:27:20
问题 When i'm outputting some of my double variables they're being written in exponential form using fwrite. Can i set some defaults in PHP where whenever a variable is displayed (copied or stored) it always happens in decimal format? To be precise the problem occurs when i use the json_decode method on a json string which contains a double value (which is not in exponential form). That double value after converting an an object becomes exponential. 回答1: Assuming the numbers are still floats when

Errors while converting np.array to decimal in Python

半腔热情 提交于 2019-12-12 02:14:09
问题 This is a continuation of the question asked here: Exponential of large negative numbers. The reason I want to use decimal is that np.exp(-large_numbers) return 0.0. Using Eric's answer to this question: https://stackoverflow.com/a/7771210/6943476, I tried converting my np.array to decimal but I still get the data-type numpy.ndarray. Coding ability: Beginner My final goal is to have a function return a damped sinusoid: def waveform(mass_sm, amplitude, F, Q, phi, Time): w = F/mass_sm print

Exponential of large negative numbers

随声附和 提交于 2019-12-12 01:36:43
问题 How does one compute a number such as np.exp(-28000) on Python? The answer is around 5E-12161. I've been told that due to the double-precision floating point format, I would only be able to calculate a number > 1e-2048 回答1: Try the decimal module. Decimal(math.exp(1))**-28000 回答2: Try mpmath for floating-point arithmetic with arbitrary precision Edit 1: >>> import mpmath as mp >>> import numpy as np >>> a = np.matrix((0,0)) >>> print(a) [0.0 0.0] >>> b = mp.matrix(a.tolist()) >>> c = b.apply

Exponential regression function Python

别来无恙 提交于 2019-12-11 18:22:54
问题 I am trying to implement a exponential regression function. sp stands for sympy. I use numpy and sympy. Firstly, in func_exp I tried to use np.exp but it generated an error (attribute error), so I decided to use sympy instead. Well, this is the code import numpy as np from numpy.linalg import matrix_rank import scipy import scipy.integrate import random import matplotlib.pyplot as plt import matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D from sympy import integrate import sympy as

Taylor Series for Exponential Function exp(-x)

穿精又带淫゛_ 提交于 2019-12-11 14:13:47
问题 I have been working on a program for Taylor Series and used long double as the number format to allow calculation of large numbers. My program works pretty fine for positive exponents, yet it fails when it comes to negative exponents. The problem is that I am getting very large positive number when I calculate exp(-x) for some x. What may be the reason behind this? Thanks for your help in advance. You can see my code here: #include <stdio.h> #include <math.h> //We need to write a factorial

Sorting the order of growth of the functions? [closed]

橙三吉。 提交于 2019-12-11 12:27:36
问题 This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center. Closed 7 years ago . Please order the function belows by growth rate from fastest to slowest: n^10 2^n nlog(n) 10^6 And my answer is: 2^n n^10 nlog(n) 10^6 Is my answer

Exponentiate very large numbers in R

南楼画角 提交于 2019-12-11 06:33:53
问题 I have the logarithms of very large values, for example: log_a = 1347 log_b = 1351 And I am trying to solve this expression: exp(log_a) - (0.1 * exp(log_b)) Or equivalently this (same expression just in a different form): exp( log_a ) - exp( log(0.1) + log_b ) But of course every time I try to compute exp(log_a) or exp(log_b) values I get Inf. Are there any tricks I can use to get a real result for exp(log_a) - (0.1 * exp(log_b)), either in logarithm or exponential form? Thank you very much

Exponentially distributed random generator (log function) in python?

家住魔仙堡 提交于 2019-12-11 00:34:03
问题 I really need help as I am stuck at the begining of the code. I am asked to create a function to investigate the exponential distribution on histogram. The function is x = −log(1−y)/λ. λ is a constant and I referred to that as lamdr in the code and simply gave it 10. I gave N (the number of random numbers) 10 and ran the code yet the results and the generated random numbers gave me totally different results; below you can find the code, I don't know what went wrong, hope you guys can help me!

Sympy: Multiplications of exponential rather than exponential of sum

爱⌒轻易说出口 提交于 2019-12-10 21:27:30
问题 I'm searching how to tell SymPy to use a multiplication of exponentials rather than an exponential of a sum. That is, it currently gives me exp(a + b) and I would want to get exp(a)*exp(b). There must be a fairly easy way but I can't seem to find it. 回答1: You could use the expand() function to show the expression with multiplication of bases rather than the sum of exponents: >>> from sympy import * >>> a, b = symbols('a b') >>> expr = exp(a + b) >>> expr exp(a + b) >>> expr.expand() exp(a)