#Inverse matrix symbolic calculator
Explore tagged Tumblr posts
bitrust · 3 years ago
Text
Inverse matrix symbolic calculator
Tumblr media
P -1, each component of which can be inexpensively computed (compared to the cost of obtaining the factors).Ī list of 3 Matrices, P, L, U, the PLU decomposition of a Matrix (these are the values returned from LUDecomposition when the output= option is given to that routine). The first member is taken as the pivot Vector and the second member as the superimposed unit-lower and upper triangular LU factors (these are the default values returned from LUDecomposition when the method=NAG option is given to that routine). That is, the list items may be:Ī list of a Vector and Matrix, ipiv, LU, for an LU decomposition. These factors are in the form of returned values from LUDecomposition. If the first argument in the calling sequence is a list, then the elements of the list are taken as the Matrix factors of the Matrix A, due to some prefactorization. The subs method indicates that the input is already triangular, so only the appropriate forward or back substitution is done. The LU and Cholesky methods use the corresponding LUDecomposition method on the input Matrix (if not already prefactored) and then use forward and back substitution with a copy of the identity Matrix as a right-hand side. The polynom method uses an implementation of fraction-free Gaussian elimination. The univar method uses an evaluation method to reduce the Matrix to a Matrix of integers, then uses `Adjoint/integer`, and then uses genpoly to convert back to univariate polynomials. The integer method calls `Adjoint/integer` and divides it by the determinant. The complex and rational methods augment the input Matrix with a copy of the identity Matrix and then convert the system to reduced row echelon form. If m is included in the calling sequence, then the specified method is used to compute the inverse (except for 1 ⁢ x ⁢ 1, 2 ⁢ x ⁢ 2 and 3 ⁢ x ⁢ 3 Matrices where the calculation of the inverse is hard-coded for efficiency). If A is a non-square m ⁢ x ⁢ n Matrix, or if the option method = pseudo is specified, then the Moore-Penrose pseudo-inverse X is computed such that the following identities hold: A -1 = I, where I is the n ⁢ x ⁢ n identity Matrix.If A is a nonsingular n ⁢ x ⁢ n Matrix, the inverse A -1 is computed such that A If A is non-square, the Moore-Penrose pseudo-inverse is returned. If A is recognized as a singular Matrix, an error message is returned. The MatrixInverse(A) function, where A is a nonsingular square Matrix, returns the Matrix inverse A -1. (optional) constructor options for the result object (optional) equation of the form output=obj where obj is 'inverse' or 'proviso' or a list containing one or more of these names selects the result objects to compute (optional) equation of the form conjugate=true or false specifies whether to use the Hermitian transpose in the case of prefactored input from a Cholesky decomposition (optional) equation of the form methodoptions=list where the list contains options for specific methods (optional) equation of the form method = name where name is one of 'LU', 'Cholesky', 'subs', 'integer', 'univar', 'polynom', 'complex', 'rational', 'pseudo', or 'none' method used to factorize the inverse of A MatrixInverse( A, m, mopts, c, out, options ) Compute the inverse of a square Matrix or the Moore-Penrose pseudo-inverse of a Matrix
Tumblr media
0 notes
program-800 · 5 years ago
Text
(An attempt at) visualising AO3 D:BH fics based on verb usage
Tumblr media
WIP. x Interactive visualisation on my Github page (link in description/Tumblr heading).
I’ve been terribly busy (at work, but also mostly in my own head). This is something I’ve been working on for a couple weekends, but I can’t get cleaner results so this write-up’s going up first while I slowly figure out improvements.
The idea was simple: can I cluster fics based on the actions that occurred within them? Obviously there’s going to be a couple clusters for smut, but how about fics which focus around character introspection, fics which focus on fluff dates, etc?
That’s what I tried here - and as is clear from the gif (tsne visualisation), the clustering didn’t work out fantastically. Details of process under the cut. Dataset is 16,211 D:BH fics published on AO3 between May 2018 to June 2020.
1. Clean up the fics. I didn’t do any stopword removal here because of step 2. Just removal of funny symbols, etc.
2. Pull out and clean the verbs. I used Spacy’s part of speech tagger for this. I also lemmatised all verbs pulled (so you may see some odd-looking words if you do explore the visualisation). Of course, sometimes the tagger misidentifies words as verbs, so you may see what should be nouns, etc. I’ve tried to remove character names at least by relying on the long list of names I created from running topic modeling on this corpus some time back.
3. TF-IDF weight the words. Basically, count how many times a verb appears in a fic, and then multiply it by the inverse count of how many fics the verb appears in. Words which are more ‘important’ or ‘representative’ of the fic in question should be weighted higher.
4. Perform non-negative matrix factorisation for dimensionality reduction. At this point, I could have possibly gone straight to tsne for visualisation with the tf-idf weights, but the results were even worse (if I recall). So I performed NMF. Like other topic modeling methods like LDA, the number of dimensions/topics to go for is user-prescribed.
I ran NMF from 10 to 60. At each point, I calculated the mean cosine similarity between all topics (we’d want something that’s lower, topics that are too similar to each other aren’t great). I picked 40 topics in the end, since that’s where the mean cosine similarity seems to level off. This is definitely a subjective call, but since I’m just really doing NMF for faster tsne visualisation, I was ok just eyeballing the graph and rolling with this.
Tumblr media
(The top 15 keywords for each topic can also be viewed on my Github page.)
5. Run tsne. I used sklearn’s implementation. I also normalised my NMF weights before submitting it for the run. I’m terribly new to tsne, so I’m pretty sure the parameters I selected weren’t great.
I went with a perplexity of 350, PCA initialisation, a learning rate of 100, a max number of 30,000 iterations with stopping if there is no improvement after 500 iterations. tl;dr, the output of tsne is heavily dependent on the parameters you set (there’s a great Distill article out there on this), and with my lack of experience I may have bungled this.
6. Visualise tsne. I used plotly’s scatterplot for this. Each dot is one fic. If you hover over the dot, you can see the top-5 tf-idf weighted verbs for it (the most ‘important’ verbs to that fic, according to the tf-idf metric).
Overall, the visualisation is more or less just a hairball, but to my amusement/chagrin, there appears to be what is a little nest of smutty-seeming fics lurking at the bottom:
Tumblr media
8 notes · View notes
tonkipie · 3 years ago
Text
Symbolic calculator wolfram
Tumblr media
Symbolic calculator wolfram code#
If you have any questions or ideas for improvements to the Derivative Calculator, don't hesitate to write me an e-mail. The gesture control is implemented using Hammer.js. Complete documentation and usage examples. poles) are detected and treated specially. Wolfram Language function: Calculate the KullbackLeibler divergence between two distributions. For each function to be graphed, the calculator creates a JavaScript function, which is then evaluated in small steps in order to draw the graph. The interactive function graphs are computed in the browser and displayed within a canvas element (HTML5). Otherwise, a probabilistic algorithm is applied that evaluates and compares both functions at randomly chosen places. If it can be shown that the difference simplifies to zero, the task is solved. For example, this involves writing trigonometric/hyperbolic functions in their exponential forms. Their difference is computed and simplified as far as possible using Maxima. The "Check answer" feature has to solve the difficult task of determining whether two mathematical expressions are equivalent.
Symbolic calculator wolfram code#
For each calculated derivative, the LaTeX representations of the resulting mathematical expressions are tagged in the HTML code so that highlighting is possible. This, and general simplifications, is done by Maxima. For example, constant factors are pulled out of differentiation operations and sums are split up (sum rule). In each calculation step, one differentiation operation is carried out or rewritten. There is also a table of derivative functions for the trigonometric functions and the square root, logarithm and exponential function. The rules of differentiation (product rule, quotient rule, chain rule, …) have been implemented in JavaScript code. Instead, the derivatives have to be calculated manually step by step. It does not merely offer a convenient way to perform the computations students would have otherwise wanted to do by hand. The presence of such a powerful calculator can couple strongly to the type of mathematical reasoning students employ. Maxima's output is transformed to LaTeX again and is then presented to the user.ĭisplaying the steps of calculation is a bit more involved, because the Derivative Calculator can't completely depend on Maxima for this task. Symbolic calculators like Mathematica are becoming more commonplace among upper level physics students. Like any computer algebra system, it applies a number of rules to simplify the function and calculate the derivatives according to the commonly known differentiation rules. Wolfram alpha can give answers in simple cases, but from my experience ISC was much more useful. Maxima takes care of actually computing the derivative of the mathematical function. Inverse Symbolic Calculator (ISC for short) is down indefinitely (and has been down for many years). This time, the function gets transformed into a form that can be understood by the computer algebra system Maxima. When the "Go!" button is clicked, the Derivative Calculator sends the mathematical function and the settings (differentiation variable and order) to the server, where it is analyzed again. MathJax takes care of displaying it in the browser. This allows for quick feedback while typing by transforming the tree into LaTeX code. The parser is implemented in JavaScript, based on the Shunting-yard algorithm, and can run directly in the browser. The Derivative Calculator has to detect these cases and insert the multiplication sign. A specialty in mathematical expressions is that the multiplication sign can be left out sometimes, for example we write "5x" instead of "5*x". In doing this, the Derivative Calculator has to respect the order of operations. It transforms it into a form that is better understandable by a computer, namely a tree (see figure below). Linear algebra: matrix operations, determinant, rank, reduced echelon form, characteristic polynomial, etc.For those with a technical background, the following section explains how the Derivative Calculator works.įirst, a parser analyzes the mathematical function.Calculus: derivatives, integrals, limits, taylor expansion, etc.Algebra: operations on polynomials, such as expansion and factorization, collecting terms, division with remainder, etc.Store unlimited number of variables, create custom functions.5/15 is 1/3 and not 0.333 (unless you select rounded numerical mode) It offers all the advantages of an advanced graphing/scientific calculator mixed with the convenience of a modern mobile app. The perfect tool for students, teachers and engineers, built on an extremely powerful algebra engine, SymCalc solves any math problems from basic arithmetics to university-level advanced math.
Tumblr media
0 notes
econobitch · 8 years ago
Link
The age of the appacus: In fintech, China shows the way | The Economist CHINESE banks are not far removed from the age of the abacus. In the 1980s they used these ancient counting boards for much of their business. In the 1990s many bank employees had to pass a basic abacus test. Today the occasional click-clack, click-clack can still be heard in villages as tellers slide their abacus beads up and down the rack. But these days the abacus is mainly a symbol, more likely to be used in the branding of China’s online-finance companies than as a calculating tool. At least three internet lenders have paid homage to it in their names: Abacus Loans, Small Abacus and Modern Abacus. The prominence, so recently, of the abacus is testament to how backward Chinese banking was a short time ago. The rise of the online lenders shows how quickly change has come. Latest updates How Hong Kong picks its chief executives THE ECONOMIST EXPLAINS Donald Trump’s proposed budget cuts would have serious implications for travellers GULLIVER Disney has drawn an outline for gay characters PROSPERO See all updates By just about any measure of size, China is the world’s leader in fintech (short for “financial technology”, and referring here to internet-based banking and investment). It is far and away the biggest market for digital payments, accounting for nearly half of the global total. It is dominant in online lending, occupying three-quarters of the global market. A ranking of the world’s most innovative fintech firms gave Chinese companies four of the top five slots last year. The largest Chinese fintech company, Ant Financial, has been valued at about $60bn, on a par with UBS, Switzerland’s biggest bank. How did fintech get so big in China? The short answer is that it was the right thing at the right time in the right place. Even after Chinese banks tucked away their abacuses, they remained remarkably unsophisticated for a high-speed economy. People accumulated wealth but had few good outlets for investing. Entrepreneurs were full of ideas but struggled to get startup loans. Consumers were spending but needed wads of cash to do so. New technology offered a way to vault over these many contradictions. During the past decade China became the country with more internet users than any other—more than 700m. A potential revolution beckoned but plodding state-owned banks were slow to respond. The terrain was open for battalions of hungry companies. Some entrepreneurs had roots in e-commerce, others in online gaming, many were just first-timers. Today, the promise of fintech in China is great. It is shaking up a stodgy banking system and helping build a more efficient one, especially for consumers and small businesses. But limitations are also clear. Banks are fighting back. And regulators, tolerant so far, are wading in. For years China has looked to developed countries for ideas about how to manage its financial system. When it comes to fintech, the rest of the world will be studying China’s experience. The rise of fintech in China is most notable in three areas. The first, obvious in daily life, is mobile payments. China’s middle-class consumers, emerging as the internet took off, have always been inclined to shop online (see chart 1). This made them big, early adopters of digital payments. China also had a late-starter advantage. Developed economies long ago swapped cash for plastic (credit and debit cards). China was, until a decade ago, overwhelmingly cash-based. The shift to digital payments accelerated with the arrival of smartphones, bought by many Chinese who had never owned a personal computer. Today 95% of China’s internet users go online via mobile devices. Alipay, the payments arm of Alibaba, an e-commerce giant, soon became the mobile wallet of choice. But it quickly faced a challenge, when Tencent, a gaming-to-messaging company, launched a payment function in its wildly popular WeChat phone app, tapping its 500m-strong user base. Baidu, China’s main search engine, followed with its own wallet. Smartpurses Competition has sparked a stream of innovations, especially in the way mobile apps can connect online to face-to-face retail transactions. QR codes, the matrix-like bar codes that generally failed to catch on in the West, have become ubiquitous in Chinese restaurants and shops. Users simply open WeChat or Alipay, scan a QR code and make a payment. And phones themselves can serve as payment cards: with another click, users display their own bar codes, which shopkeepers then scan. And it is as easy for people to send money to each other as it is to send a text message—a vast improvement over the bricks of cash that used to change hands. Many of the payment functions within WeChat or Alipay exist elsewhere in the world, but in disaggregated form: Stripe or PayPal for online shops processing payments; Apple Pay or Android Pay for those using their phones as wallets; Facebook Messenger or Venmo for friends transferring money. In China all these different functions have been combined onto single platforms. Adoption is widespread. For about 425m Chinese, or 65% of all mobile users, phones act as wallets, the world’s highest penetration rate, according to China’s ministry of industry and information technology. Mobile payments hit 38trn yuan ($5.5trn) last year, up from next to nothing five years earlier—and more than 50 times the size of the American market. Small is beautiful A second area where China has become the global leader is online lending. In most countries, banks overlook small borrowers. This problem is especially acute in China. State-owned banks dominate the financial system, with a preference for lending to state-owned companies. The absence of a mature system for assessing consumer credit-risk adds to banks’ reluctance to lend to individuals. Grey-market lenders such as pawn shops provide financing but at usurious interest rates. Fintech has started to fill this gap. E-commerce was again the launch-pad: online shopping platforms developed loan services, and are using their customers’ transactions and personal information to create credit scores. (How the government might eventually harvest data for social control is cause for concern, but for now lenders are merely trying to master the basics of credit ratings.) Shoppers on Alibaba and JD.com, China’s two biggest e-commerce portals, can conveniently borrow small amounts, typically less than 10,000 yuan. According to Ant Financial (Alibaba’s financial arm, spun out in 2014), 60% of borrowers in this category had never used a credit card. On their platforms, Ant and JD.com also lend to merchants, many of whom are the kinds of small businesses long ignored by banks. However, e-commerce lending is intrinsically cautious. Its targets are clients already well-known to the big shopping platforms. For the more radical side of China’s online lending, look instead at the explosion of peer-to-peer (P2P) credit. From just 214 P2P lenders in 2011, there were more than 3,000 by 2015 (see chart 2). Initially free from regulatory oversight, P2P soon morphed into China’s financial Wild West, brimming with frauds and dangerous funding models. More than a third of all P2P firms have already shut down. Yet P2P lenders still have a big role to play in China. Despite a string of headline-grabbing collapses, the industry has continued to grow. Outstanding P2P loans increased 28-fold from 30bn yuan at the start of 2014 to 850bn yuan today. The online lenders answer a basic need, like China’s grey-market lenders of old, but in modern garb and, thanks to all the competition, offering credit at lower interest rates. In other countries, P2P firms typically lend to clients online and obtain funding from institutional investors. The most successful lenders in China flip that approach on its head. Because of the lack of consumer credit ratings, they vet borrowers in person. Lufax, China’s biggest P2P firm, operates shops—more than 500 in 200 cities—for loan applicants. And for funding, Chinese P2P firms draw almost entirely on retail investors. More than 4m people invest on P2P platforms, up by a third over the past year. The platforms can then divide loans into small chunks, parcelling them out to investors to disperse risks. This points to the third area of China’s fintech prowess: investment. Until recently, Chinese savers faced two extreme options for managing their money: stash it in bank accounts, where interest rates were artificially low, but it was as safe as the Communist Party; or punt on the stockmarket, about as safe as playing baccarat in a casino in Macau. “In the middle there was nothing,” says Huang Hao, vice-president of Ant Financial. Fintech has opened that middle ground. In the West asset managers increasingly worry that they face a wave of disintermediation as investors migrate online. In China asset managers barely had a chance to serve as intermediaries in the first place; the market skipped into the digital stage. In large part this resulted from a generational divide that is the inverse of the global norm: the best-paid workers in China tend to be younger, the country’s first big generation of white-collar workers. They are much more likely to be willing to trust web-based platforms to manage their money. “In America people love technology, too, when they are 22. They just don’t have any money,” says Gregory Gibb, Lufax’s chief executive. The biggest breakthrough was the launch of an online fund by Alibaba in 2013. This fund, Yu’e Bao (or “leftover treasure”), was promoted as a way for people to earn interest on the cash in their e-commerce accounts. The appeal, though, turned out to be much broader. Invested through a money-market fund, Yu’e Bao offered returns in line with the interbank market, where interest rates float freely (see chart 3). This meant that savers could get rates that were more than three percentage points higher than those banks offered. And risk was minimal, because their cash was still ultimately in the hands of banks. Yu’e Bao attracted 185m customers within 18 months, giving it 600bn yuan of assets under management. As is so often the case in China, new entrants soon appeared. In 2014 Tencent launched Licaitong, an online fund platform linked to WeChat. Within a year, it had 100bn yuan under management. Lufax, meanwhile, outgrew its P2P roots to transform itself into a financial “supermarket”, offering personal loans, asset-backed securities, mutual funds, insurance and more. Robo-advisers (firms that use algorithms and surveys to let users build portfolios) also have China in their sights. Give me your pennies And it is not just about wealthy investors. In the West people generally need deep pockets before they can afford to buy into products such as money-market funds. In China all it takes is a smartphone and an initial buy-in of as little as 1 yuan. WeChat, with 800m active accounts, and Ant, with 400m, can afford to be generous. How to gauge the impact of fintech in China? Measured against the rest of the country’s colossal financial system, the various fintech pieces are puny. Apps and online lenders might have massive user bases, but they are mainly comprised of consumers and small businesses, not the hulking state-owned enterprises and government entities that form the backbone of the banking system. The outstanding balance of P2P credit is roughly 0.8% of total bank loans. Credit provided by the e-commerce firms adds up to even less. Earnings from mobile payments amount to barely 2% of bank revenues. Wei Hou, an analyst with Bernstein Research, reckons that the fintech firms will grab less than a twentieth of banks’ business by 2020. That is hardly to be sneezed at, since it comfortably equates to 1trn yuan in revenues. But it is not the kind of radical disruption that fintech’s more ardent evangelists often foretell. Nevertheless, just looking at the overall size of fintech is insufficient. In the market segments they have set their sights on, fintech firms have made a big mark. Digital payments account for nearly two-thirds of non-cash payments in China, far surpassing debit and credit cards. P2P loans make up about a fifth of all consumer credit. What’s more, fintech firms have provoked a competitive response. Take the customer experience at China’s biggest banks: it has improved markedly over the past few years. Once-cumbersome online-banking portals are much easier to use. Even more important, banks are also changing their business models. Prodded in part by the online investment funds, they have moved away from their plain-vanilla deposit-taking roots. Their focus has shifted to “wealth-management products” (WMPs), deposit-like investments which they sell to their clients, often via mobile apps. Returns are as high as anything on Alipay or Tencent. The banks’ apps are not as slick, but not far off, and they feel far safer, with their reassuringly physical thousands of branches. The outstanding value of WMPs has reached more than 26trn yuan, quadrupling in five years. WMPs have brought new risks into the financial system, in particular concerns over banks’ funding stability. But they have arguably done more to promote interest-rate liberalisation than any regulatory edict. And banks have come to appreciate their own strengths: branch networks; solid reputations; and risk controls. “You can’t say that banks or fintech firms are better positioned. Both need each other,” says Li Hongming, chairman of Huishang Bank, the main lender in Anhui, a big central province. Fintech upstarts have also learned that lesson. Look at Wheat Finance, one of the country’s earliest P2P lenders, established in 2009. Amy Huang, Wheat’s CEO, says her initial goal was to challenge banks on their home turf. But she soon realised that banks have insuperable advantages, with their stable, low-cost funding bases. Instead of battling them, Wheat is becoming their partner: 70% of its revenues come from selling digital services to banks. Regulatory attitudes are also shifting. China’s government initially gave fintech companies a free hand, a striking contrast to its heavy policing of traditional banks. The hunch was that fintech firms were small enough for any problems to be manageable, and might produce useful innovations. This wager paid off: the rise of mobile payments and online lending owe much to light regulation. But the era of benign neglect is over. In 2016, provoked in part by the P2P scandals, China introduced regulations to cover most fintech activities. Most of the rules are aimed at making fintech safer, not at curbing it. Firms can no longer pursue their most ambitious strategies. Individuals, for instance, can borrow no more than 200,000 yuan from any one P2P lender. Some of the regulations, though, also constrain what fintech firms can hope to achieve. The central bank is overseeing the creation of an online-payments clearance platform. It wants transparency: all digital payments will be visible to the central bank. But it could neutralise one of the main advantages of Ant and Tencent, forcing them to share transaction data with banks. It seemed, for a time, that China’s internet titans might go after banks’ crown jewels, when they obtained licences to run online banks. But the government has required that they act in partnership with existing banks for even the most basic functions such as deposits and withdrawals. Yet this is not the end of the road. Ant and Tencent still have hundreds of millions of users between them on apps that offer a wide range of financial services and products. They just need to persuade enough users to view them not simply as mobile wallets but as mobile brokers and lenders. As Lufax and JD.com hone their offerings, they, too, will grow more powerful. Regulations have placed speed bumps along their path. But the path is still there. The Chinese are coming China’s fintech champions are also trying to break into new territory abroad. WeChat’s mobile wallet is usable internationally, mostly in Asia for now. Ant has invested in mobile-finance companies in India, South Korea and Thailand. But replicating their successes in other markets will not be straightforward. Much of their repertoire was devised specifically to address deficiencies in China’s financial system. And anything that touches on core banking abroad will require local incorporation and adherence to local regulations—headwinds against global expansion. China’s bigger impact is likely to be indirect. Its fintech giants have shown what can be done. For emerging markets, the lesson is that with the right technology, it is possible to leapfrog to new forms of banking. For developed markets, China offers a vision of the grand consolidation—apps that combine payments, lending and investment—that the future should hold. And the biggest lesson of all: it is not upstarts versus incumbents but rather a question of how banks absorb the fintech innovations blossoming around them. China, an early adopter of the abacus, is, after a long period of dormancy, once again blazing a trail in finance.
0 notes