text:
A Cloud & AI Strategy

Imagine its 2005 and you somehow knew that cloud, data, AI computing will be a thing for the next 10 to 20 and even more years.
You handpicked a number of big companies and you ran your backtest.

Or may be, you want to run this strategy for the future, and wonder how those companies performed in the past.

# Selected Stocks

• MSFT, for Azure AI Services
• ADBE, for its Analytics Suite
• AMZN, for AWS AI Services
• IBM, for IBM Watson
• GOOG, for Google Cloud AI Services
• CRM, for buying AI startups
• SAP, for participating in AI research

# Results

What do you get: above 1300 percent return, low variance, tax efficient portfolio.

# Details

• Hold only stocks that are in the pre-selected list and Q1500 universe
• Rebalance, if a new stock enters or exits, or every 270 days after the last rebalance
• Rebalance by splitting the cach or the value of the portfolio equally

# Caveats

• With the benefit of hindsight everyone can pick stocks
• There is no clear rule when to ditch a stock, e.g. if it falls too much or it does not make a lot of progress
• Weighting is equal, which means when you rebalance, you give more to stocks that underperformed

# Disclaimer

This presentation is for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation for any security; nor does it constitute an offer to provide investment advisory or other services by the author or anyone else. Nothing contained herein constitutes investment advice or offers any opinion with respect to the suitability of any security, and any views expressed herein should not be taken as advice to buy, sell, or hold any security or as an endorsement of any security or company. This disclaimer was adapted from Quantopian's own disclaimer.

19
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
 Returns 1 Month 3 Month 6 Month 12 Month
 Alpha 1 Month 3 Month 6 Month 12 Month
 Beta 1 Month 3 Month 6 Month 12 Month
 Sharpe 1 Month 3 Month 6 Month 12 Month
 Sortino 1 Month 3 Month 6 Month 12 Month
 Volatility 1 Month 3 Month 6 Month 12 Month
 Max Drawdown 1 Month 3 Month 6 Month 12 Month
import quantopian.algorithm as algo
from quantopian.pipeline import Pipeline
from quantopian.pipeline.data.builtin import USEquityPricing
from quantopian.pipeline.factors import AverageDollarVolume, SimpleMovingAverage
from quantopian.pipeline.factors import CustomFactor
from quantopian.pipeline.data import USEquityPricing

import numpy as np
import pandas as pd

from quantopian.pipeline import Pipeline

from quantopian.pipeline.filters import Q1500US

from quantopian.pipeline.data import Fundamentals
from quantopian.pipeline.data.builtin import USEquityPricing

def initialize(context):
context.i = 0
context.changes = 0
# parameters:
# which cloud stocks we want to use as our universe
context.cloud_tickers = symbols('MSFT', 'ADBE', 'AMZN', 'VMW', 'IBM', 'GOOG', 'CRM', 'SAP', 'RHT', 'ORCL', 'RAX')
# data & AI, no infra
context.cloud_tickers = symbols('MSFT', 'ADBE', 'AMZN', 'IBM', 'GOOG', 'CRM', 'SAP')

# how many days back we use average dollar volume as filter
context.average_dollar_volume_formation_period = 270

algo.schedule_function(
rebalance,
algo.date_rules.every_day(),
algo.time_rules.market_open(hours=1),
)

algo.schedule_function(
record_vars,
algo.date_rules.every_day(),
algo.time_rules.market_close(),
)

algo.attach_pipeline(make_pipeline(context), 'pipeline')

def make_pipeline(context):
q1500us = Q1500US()

cloud_tickers = StaticAssets(context.cloud_tickers)

screen = (cloud_tickers & q1500us)
pipe = Pipeline(
columns = {'dv': dollar_volume})

pipe.set_screen(screen)
return pipe

"""
Called every day before market open.
"""
context.output = algo.pipeline_output('pipeline')['dv']
context.security_list = context.output.index

def rebalance(context, data):
context.i += 1
selected_stocks = []
for stock in context.output.index:
v = context.output.at[stock]
if v > 0:
selected_stocks.append(stock)
for stock in list(context.portfolio.positions.iterkeys()):
if stock not in selected_stocks:
print("closing position for " + str(stock))
order_target_percent(stock, 0)

old_stocks = list(context.portfolio.positions.iterkeys())
cond_1 = set(old_stocks) != set(selected_stocks)
cond_2 = (context.i > 270)
if cond_1:
print("old stocks != new stocks")
if cond_2:
print("rebalance after 270 days")
cond = cond_1 or cond_2
if cond:
context.i = 0
context.changes += 1
for stock in selected_stocks:
v = 1.0/len(selected_stocks)
print("open position for " + str(stock) + " " + str(v))
order_target_percent(stock, v)

def record_vars(context, data):
"""
Plot variables at the end of each day.
"""
record(leverage=context.account.leverage)
record(changes=context.changes)

def handle_data(context, data):
"""
Called every minute.
"""
pass
There was a runtime error.
13 responses

I got interested in Stefan's trading strategy after seeing the “Cumulative Return on Logarithmic Scale” in a tearsheet. It showed alpha generation. This is represented by the steady widening of the spread between the algo and its benchmark.

I understand that this is a niche trading strategy specifically oriented on cloud and AI computing. Nonetheless, we should look at the stock market with a long-term perspective. And forecasting that we will need more from our machines should be considered as an understatement. With the advent of G5, this trend will accelerate and enable all new kinds of devices (IoT) requiring even more storage and services. Therefore, such a niche market should continue to prosper over the years.

Stefan's analysis and disclaimer are accepted.

Nonetheless, I opted to reengineer the strategy as I did in the Robot Advisor thread. I started by appraising a Buy & Hold scenario for the same stocks over a slightly different period: from 2003-09-12 to 2018-09-14, in order to compare the program's modifications over the same duration. Also upped the initial capital to 10M.

This scenario produced the following results:

However, this should be compared to letting the strategy do its trading thing. This to answer the question: was the Buy & Hold more or less productive than the original trading strategy with the added capital?

As can be observed, the Buy & Hold outperformed the 13 months rebalancing. It should be noted that no leverage was being applied and that all Q default frictional costs were included.

This trading strategy provides a trading environment which chooses periodic rebalancing as its main course of action. And as Stefan explained, the equal weights forced the selling of part of the rising stocks to increase positions in the lagers. Which also explains why the Buy & Hold outperformed the strategy.

Now the reengineering part.

Even if it was interesting, the rising equity curve, the outperformance of the benchmark, I still did not find it enough especially since the strategy did not outperform a simple Buy & Hold in a niche market that was made to prosper and will continue to do so.

I'll skip some of the steps since just by reengineering the code you have to make quite a few simulations just to verify that the code does not crash, does what it is supposed to do and that there are no bugs. I reengineered twice since I was not satisfied with the limitations of the first method even if it provided more than interesting results.

Whatever trading strategy you have you need to have it financed and have it scalable. The code was there to make the strategy scalable. But still, finance was limited to the 10M of initial capital. In order to increase the impact, some leveraging would be needed. I know some hate leveraging but it has its use in scenarios where you can outperform the averages. In a way putting more pressure and improving one's trading edge which was already built-in the stock selection itself.

So, I put in some downside protection and added some leveraging to the mix. Changed the orientation of the strategy itself and allowed it to go short at times. The payoff matrix of a trading strategy can be resumed in two numbers: the number of trades over the trading interval and the average net profit per trade. Both numbers are provided when using the “round_trips = True” option of the tearsheets.

Therefore, the objective is to increase either or both of these numbers in order to increase overall CAGR performance. Other numbers might not have an impact on final results, and in a compounding game, the final outcome, the end-game is what really matters. Evidently, you will try to make it within acceptable volatility and drawdown constraints, making them as low as you can without destroying your strategy's potential. To reduce volatility and drawdowns, I increased the number of stocks to 25, thereby reducing the bet size.

With the first method, it generated the following:

Interesting, but not enough. Not enough trades:

I wanted more.

I changed the trading methods in order to accelerate the thing. It also meant increasing the use of leverage in order to supply more funds to the methodology and accepting shorts.

It generated more trades, provided a higher overall return. Beta decreased, Both Max Drawdown and volatility slightly increased. The average net profit per trade decreased, but this was compensated by the higher number of trades resulting in more generated profits. The average gross leverage came in at 1.48.

I opted to be more aggressive. It raised the gross leverage from 1.48 to 1.57. At the same time, I was lowering the max drawdown, the volatility and the average beta which came in at 0.48 on average. An overall improvement.

This was counterintuitive. To do so, I allowed a lot more shorts in the picture in a rising market. To the point that shorts dominated in numbers of trades. As if allowing more shorts was enabling the longs to profit more.

Not only did the number of trades increased considerably, but the average net profit per trade also went up resulting in much higher profits.

There is the cost of leveraging that has to be addressed, but I will keep that for later on. Nonetheless, the formula would be for the last test: 1.57∙F_0∙(1+0.629 – 0.57∙0.08)^15, or 1.57∙10M∙(1+0.6285)^15, on the basis that leveraging fees would be at 8%. It will make a difference over the long term, but it should be considered as some kind of frictional cost. You want more, you have to do more than your peers, and there is a cost to it.

By accepting more in the gross leveraging department, you could push for even more with not that big a deterioration in the volatility, beta and max drawdown figures, as illustrated in the following:

The portfolio metrics for the above came in at:

Gross leverage went from 1.57 to 1.62. Average beta went for 0.48 to 0.53. While max drawdown went up from -30.5% to -31.4%. All these measures were more than acceptable for the added overall performance. Nonetheless, some might not like operating at these levels, but it should be noted that even if we started with an average beta of 1.07, we still ended with an average beta of 0.53. Meaning that the overall strategy is swinging less than the average market as a whole. The statistics for this version of the program came in at:

The point being made in this demonstration is that a trading strategy can start with a specified architecture, then it can be modified to do even more by putting the emphasis on two numbers: the number of trades and the average net profit per trade. A strategy can evolve to do more, it is up to us to make it do so. And as said before: if you want more, you will have to do more.

I would point out that it is not the numbers that were the most important, it was the process itself. The trading methods used to survive in a sea of variance. Hope it was instructive just to study the process described in this post.

Thanks Guy,
Very interesting. Just wondering if you can share the code for your backtests. I did not get how you choose the short positions.

Thanks,

Stefan

However, of note, your trading strategy started scalable by design. You could push on its pressure points in order to increase the number of trades and the average net profit per trade. These were modulated. Most of it was done by leveraging and adding protective measures for when the equity line decreased by either reducing positions sizes or going short.

The reengineered strategy mechanics were added to see how far I could push the outcome before it blew up for some reason or other. I have not reached that limit yet since there is still room to increase performance even further. Because the strategy is scalable, all I need to do is increase the leveraging a little bit more. The leveraging is compounding which leads to higher performance results over the long term. Evidently, there is a limit to this, but I have not pushed that far yet.

Notwithstanding, I also did the test of removing all the leveraging with the following results:

The above compared to the last equity chart presented in my last post does show the impact the leveraging had to play on the strategy's outcome. This did not affect the protective measures which stayed in place. However, from this move, it showed that the high number of shorts were not there to make money, even if they did, but to protect the portfolio's downside as illustrated in the following chart:

Nonetheless, the strategy generated more trades simply due to its reduced bet size, but still managed to be interestingly productive profit wise.

The more relaxed trade mechanics of the strategy can also be seen in the portfolio metrics as illustrated below:

As expected, after removing the leveraging, gross leverage went down to 0.97. But this also had an impact on average volatility which went down to 19.2% while max drawdown also got lower to -25.0%. In all, interesting numbers. Portfolio stability is at 0.99 and the beta was down to 0.14.

If the theoretical CAPM expectation for a trading strategy is to get the long term market average as in: E[F(t)] = r_f + β∙(E[r_m] – r_f), we should expect that with a beta of 0.14, we should not get there. At the very least, I should not be able to present the above numbers.

But that is the whole point of trading. As if we should not use the math of a Buy & Hold scenario and force it on a trading system which has its own mechanics and which tends to recycle its ongoing profits as in this strategy. We should question the how and the why we force our programs to do things.

From these tests, I was able to push the performance limits due to the added trade mechanics, the protection measures and the leveraging. Once I'll know the limits, which I have not attained yet, I could scale back to whatever level I felt more comfortable, with the notion that I could still apply pressure where I wanted to if desired knowing that the strategy would support it. The whole process forced me to add better protective measures which the strategy could benefit from even if no leveraging was applied.

Notice the value of the leveraging in this case. The leveraging added 24.6 times more profits than the no leveraging scenario. And in numbers, it added $24.6B to the portfolio just because you scaled it up by using some leveraging. There would be more than enough to cover the leveraging fees. Those are all choices we have to make. It is why we make these tests to see how far we can go, what are the mechanics of the trade, what is it you really want to do, and how much risk are you willing to take. One thing is sure, if you want more than your peers, you will have to do more than they do. @Guy: It is totally up to you whether you decide to share your algorithm or not, it's your IP! That said, could you please start a new thread with your commentary and link back to this one? Given the length and level of detail of your comments, I think you may have inadvertently 'overtaken' this thread with your content and it becomes hard for anyone else to contribute, especially others who might want to iterate on Stefan's idea and publicize their version. I'd just like to be respectful to Stefan who started the thread! P.S. You can always share a pyfolio tearsheet by sharing a notebook without sharing the algorithm code. It's usually a more reader-friendly method than posting large screenshots. Disclaimer The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. Hi Stefan, Thanks for sharing. As you suggest, hindsight is 20-20. The ROI would also be phenomenal if only in hindsight we had chosen the correct lottery ticket as well. Alas, if that were possible, in practice the winnings would end up being split among so many winners as to leave us with a loss. It's important to be aware of selection bias and recency/framing bias. It's not entirely outside of the realm of possibility that one year from now we'll all be laughing at the failure of the cloud computing investment thesis. I think it's difficult to algorithmically decide which secular themes will win out and have not yet been "priced in," at least from a statistical perspective there simply wouldn't be enough data points to draw a significant conclusion. The literature would indicate that you can't turn to stock analysts for this prediction -- they're only right ~49% of the time. (But of course there are the Peter Lynches of the world.. but how are we to know who to trust?) I think your example does show that the market did not fully appreciate the information it had in 2005. In hindsight, Bezos was pretty clear about his plan. So was the market pricing in a risk that didn't materialize? Or did it simply under-appreciate the market opportunity? Or what happened? For me it's crystal clear that the next huge secular trend will be AI. Much of what we do -- including things we can't even imagine yet -- will be replaced or at least augmented by AI tools. This will be powered by both cloud AND edge computing. Does this make AI a good investment thesis? Is it already priced in? Many players are already very expensive. Though the market opportunity may not be fully appreciated yet. Hard to know. Are the risks large? There are geopolitical risks -- even the trade wars with China is having a huge negative impact on share prices of many AI names even though in the long-run it won't matter at all. There are market risks -- volatility, global economic health, etc. Ultimately, I do think it is a good investment thesis, despite the risks. However, I don't think it makes any sense in the context of a Quantopian long-short hedged algo strategy, because it's likely to incur short-term volatility (on top of the selection bias issues). Your example clearly demonstrates that even with 20-20 hindsight, investing in the biggest secular trend of the last decade only resulted in a 0.89 Sharpe ratio. That's nothing to write home about. The drawdown is pretty rough (though the market drawdown is similar). I think 0.11 alpha is probably pretty damn good for a large cap universe, but if you removed market beta from the equation the returns would not be so utterly amazing. The 1300% returns are largely thanks to the power of time, modest outperformance, and the incredible power of compounding. And hindsight, of course. @Viridian, you say: It's important to be aware of selection bias and recency/framing bias. It's not entirely outside of the realm of possibility that one year from now we'll all be laughing at the failure of the cloud computing investment thesis . How silly can one get? If I am allowed to use that word? Isn't that like the statement made in 1895 by the director of the US Patent Office who quit his job on the grounds that everything had already been invented and therefore there was no more need for him or his job? Or something by the president of IBM in 1962 saying that they would probably sell at most 4 or 5 computers in the coming years. Am I to understand you view computing as a fad and probably by next year it will all be over? Could I add the words: think again! You do not need 20/20 hindsight to state, “guess”, or whatever, that in the coming years computing will continue to expand. Not only that, it will continue to expand at an exponential rate. I don't want to get too far off on a tangent, but put simply: just because something is a popular product does not mean it is a good investment. Xerox is a great example. Changed society.. but not so much for its investors. Increased competition could lead to margin pressure. Commodization. Supply chain disruption. Rise of edge computing. Multiple compression. There are risks to any investment thesis, including this one. Read again what I wrote and you may realize your response is a total non sequitur. I will not fall into that trap. I will let everybody determine their own views, expectations, and on what they should bet going forward. It is their choice, it is not mine to make. Nonetheless, I do wish you extreme luck in shorting this non sequitur computing “fad”. Nobody is talking about shorting anything. My contribution to the discussion was about (un/)certainty/risk and cognitive biases. Please put forth an effort, read carefully, and not misconstrue. Once again you are hi-jacking a thread. I'm a great believer in the tech industry as well. Unfortunately my basket of tech stocks didn't do quite as well: MicronPC Netscape Palm Napster TheGlobe.com Compaq InfoSpace GeoCities eToys.com iOmega AltaVista Polaroid Wang Laboratories Pets.com 3dfx MySpace Commodore Syquest Gateway Computers Iridium Atari Thanks though to @Stefan for the original post. I find it both interesting and helpful! @Joakim, if you added just 2 years to Q's datasets, thereby, going back to 2000, you could add some 1,300+ stocks to your list. Is there risk playing the markets? YES. Will the earth stop turning tomorrow? NO. Will all the people on the planet go into an economic coma tomorrow? NO. Will all cars or computers or whatever stop working tomorrow? NO. How long should that list be? If something has a probability of occurrence of less than 0.000000000000000000000000000000000000001, how and incredibly why did it ever enter into your day-to-day trading considerations. Nonetheless, the whole point is that it is our job to identify what we want to play with. And if we are playing long and cannot realize that our stock list is going down the drain, it is not the market that is to blame but our stock selection process and our trading methods. For instance, take the next chart. Should you get out today, or would your trading program have acknowledged that it should have done so much much sooner? Yes, easy! To quote Will Rogers: “Don't gamble; take all your savings and buy some good stock and hold it till it goes up, then sell it. If it don't go up, don't buy it.” @Joakim, Will Rogers was right. I used that same quote on my website years ago, but I read it differently. And I think Mr. Buffett also adheres closely to that same pun. We should indeed buy stocks that are going up, and not what is going down. Better yet, we should buy stocks that have shown they have been going up and continue to have future positive prospects. It is our business to find and isolate the stocks that will tend to go in the same direction as our bets, that these be long or short. Berkshire Hathaway went from about$10 to about $320,000 over the past 50+ years while following in step with the vagaries of the market. How long should it have taken to notice it was on the rise at some point along the way? From 2002 to today, it went from 74k to 320k. That is an increase of$246,000 per share.

Yet, I have never seen it traded in any of the simulations presented on Q. Already, prior to 2002, it had gone up from $10 to$74,000, all the time making high after high over some 30 years. This gave anyone over 10,000 days to figure out that, well, “maybe”, it was going up. It has been going up now for over 18,000 days. Hope no one kept a mean-reversal thing on this one, or held long-term shorts.

Worse yet, the general market has been going up too, on average, for over 88,000+ days. Should you wait another 88,000 days because you have doubts about where the market will go over the next 10 to 20 years?

We need to observe that we should buy good stuff that is going up and wait for its price appreciation.

IF the price does not generally go up, you get rid of that stock.

Over the past 50 years, world population has grown from 3.6 billion to 7.5 billion. And over the next 30 years, we will add another 2.0 billion. The world will continue to prosper, companies will have to supply what people need and/or want. A lot of companies will prosper in doing so, and others won't. But, it has always been like that, it is the nature of business. So account for it, even in your trading strategies.

We are all doing backtests over past data in order to figure out what has a higher probability of helping us going forward, where it will count or not, in real money that is, and not simulation money. But, it will all depend on you and your trading programs.

It is not the market that is throwing you a curveball (it has been going up on average over the long term and most highly probable will continue to do so), it is your strategy design that might be ill-suited, misfitted, or poorly designed for its future job.

What I am waiting for is that you simply challenge the math I presented. I can take it. There are equal signs all over the place. You will need to demonstrate a not equal sign and provide the grounds on which it is based. Surprisingly, in the process, you will be helping me design even better systems. But, I think that is too much to ask? Anyway, consider it an open invitation. Mostly, I consider my math stuff to be more like: 2+2 = 4, or is it: 4 = 2+2.

My first post in this thread showed that the strategy over the same time interval did NOT even outperform a simple Buy & Hold scenario using the same stocks.

The initial trading strategy had nothing special. It lived in a simple and basic long-term Markowitz 54-week rebalancing act. The type commonly found on so many Quantopian strategies using its scheduled rebalancing function.

Therefore, whatever the stock selection, the bar was set, and my early simulations clearly demonstrated that it was preferable to adhere to a Buy & Hold scenario than to execute the initial strategy since: $$\sum (H_{(spy)}∙ΔP) > \sum (H_a∙ΔP)$$.

The objective became to reengineer this code, resulting in this new strategy H_b, so that the following could prevail: $$Σ(H_b∙ΔP) > Σ(H_{(spy)}∙ΔP) > Σ(H_a∙ΔP)$$ and thereby not only outperform the original trading script but also the Buy & Hold scenario which implicitly became the strategy's own benchmark.

The mathematical artistry came from generating alpha over and above this benchmark based on whatever trading methods I could use even if I needed to revamp almost the whole strategy over its initial Quantopian-like strategy template.

Just more stuff to think about.


text:
# Calculate curl of rotating bucket of water

## Homework Statement

A bucket of water is rotated slowly with angular velocity w about its vertical axis..When a steady state has been reached the water rotates with a velocity field v(r) as if it were a rigid body. Calculate div(v) and interpret the result. Calculate curl (v). Can the flow be represented in terms of a velocity potential such that v = grad phi? If so, what is phi?

## The Attempt at a Solution

Not sure how to do this...
I think somewhere in my notes it says that v here should = (-wy,wx,0)

Is this right?

In which case, div(v) = 0 - what is the interpretation?? No sinks or sources??
curl v = (0,0,2w)...

Can I write it as the gradient of a scalar function? If so, what is the function?

## Answers and Replies

Related Introductory Physics Homework Help News on Phys.org

I just don't see how to write it as the gradient of a scalar function basically..

anyoneee?

I just don't see how to write it as the gradient of a scalar function basically..
The most simple approach here would be to draw a diagram showing the velocity vector, and how it's always perpendicular to the radius vector. (Every droplet goes around in a circle with its energy constant)

This yields:
$$\vec v= -\omega y \hat x +\omega x \hat y$$

Taking the divergence of this function, does indeed get you 0. That means no sources or sinks are present.

Taking the curl, however, shows you that this vector field does have a curl!

$$\nabla \times \vec v= 2\omega \hat z$$

A vector field that can be represented as the gradient of some scalar function must always have 0 curl. (Some googling brought up this: http://en.wikipedia.org/wiki/Conservative_vector_field)

Note that it is a mathematical identity that $$\nabla\times\nabla\phi=0$$ making it impossible for a gradient to have non-zero curl.
If a vector field can be represented as the gradient of a scalar function, then it MUST have 0 curl.
However, if a vector field has 0 curl, the converse is not true in general, you may be able to represent it as the gradient of a scalar function, and you might not be able to do so.

Last edited:

format: plain


text:
# Divergence theorem to prove a relation.

I found this problem, I wanna do. Let $f$ be continuesly differentiable, let $r=\sqrt{x^2+y^2+z^2}$ Prove $\iint \limits _S \vec f (r) \cdot \vec n \ \Bbb dS = \iiint \limits _B \vec {f'(r)} \cdot \frac {\vec r} r \ \Bbb dV$ where left integral over sphere, right over the ball both of radius $R$.

I tried to apply divergence theorem using that $\vec n=(\frac x r,\frac y r, \frac z r)$. I could not get anything out of that.

I tried to then to work in case $f$ is a vector field, I got the right hand side: $\iiint \frac {f'(r)} {r} \cdot (-2x,-2y,-2z) \ \Bbb dV$.

Any help please. I am also interstate what case we can get if $f$ is scaler. I feel like there is a confusion with notation.

• if f is scalar you cannot use the divergence theorem. can you? – Sepideh Abadpour Aug 14 '15 at 19:16
• Yes, I multiply f with constant vector – user65304 Aug 14 '15 at 19:19
• I have modified part of your question in order for it to make sense mathematically. You put arrows above symbols by writing "\vec {my_symbol}". – Alex M. Aug 14 '15 at 19:19
• @Alex is f scalar or vector field. if it's scalar, you cannot write $\vec{f'(r)}$ you should write $f'(\vec r)$ – Sepideh Abadpour Aug 14 '15 at 19:20
• @sepideh: Arrow over the wrong symbol, thank you for noting. Now it's fine ($\vec f$ is a vector function with spherical symmetry, therefore depending only on $r$, not on $\vec r$). – Alex M. Aug 14 '15 at 19:26

You solve this by applying the divergence theorem. Note that $\vec {f(r)}$ is a vector-valued function with spherical symmetry (that is, it does not depend on $\vec r = (x,y,z)$, but only on its norm $r$). By the chain rule, the divergence here will be
$$\operatorname{div} \vec f = \operatorname{div} {(f_x, f_y, f_z)} = f_x ' (r) \frac {\partial r} {\partial x} + f_y ' (r) \frac {\partial r} {\partial y} + f_z ' (r) \frac {\partial r} {\partial z} = (f_x ', f_y ', f_z ') \cdot (\frac x r, \frac y r, \frac z r) = \vec {f'(r)} \cdot \frac {\vec r} r$$
• Would the same result hold if $f$ is scaler, and multiply by constant vector.? – user65304 Aug 14 '15 at 19:41
• if f is scalar and n vector, you can not write $f.n$ in left-hand side? what's the notation of the problem exactly? can you post a photo of the problem. Alex M's answer is for the vector case if F is scalar you can not define divergence – Sepideh Abadpour Aug 14 '15 at 19:55
• @sepideh: The OP wonders whether the dot $\cdot$ means inner product (as in my solution above) or the product of a scalar function and a vector. – Alex M. Aug 14 '15 at 19:57
• Sepideh, I agree with what you said. What I am trying to say, if I use the divergence theorm on $F(x,y,z)=f(x)(c_1,c_2,c_3), \ \ where \ c_i \ are \ constants$ Now apply the divergence theorm $\iint \limits _S cf (r). \ \Bbb dS = \iiint \limits _B( c.\bigtriangledown f + f \ (\bigtriangledown c))\ \Bbb dV$ second term on right hand side will vanish. then I did not carry out the calculation, as I am not sure if it will yield anything similar. – user65304 Aug 14 '15 at 21:14


text:
# Are rational and irrational numbers real numbers?

Yes.

#### Explanation:

Real numbers are often explained to be all the numbers on a number line.

Consider that there are two basic types of numbers on the number line. There are those which we can express as a fraction of two integers, the Rational Numbers , such as:

$\frac{1}{2} , \frac{5}{3} , \frac{22}{7} , - \frac{3887}{4} , e t c$

and those which we can't express as a fraction, the Irrational Numbers :

$\sqrt{2} , \pi , e , - \sqrt{5} , e t c$

(note that while $\frac{22}{7}$ is an often used approximation for $\pi$, $\pi$ itself can't be expressed as a fraction).


text:
# Classical Probability Model

• September 29th 2009, 04:45 PM
gconfused
Classical Probability Model
Hi, well I'm totally lost with this subject, and this is an easy question but I just don't understand ..
Question: A fair coint is flipped n = 100 times. What is the probability to have exactly k = 50 heads? What is the probability to have exactly n/2 heads when n is even?

Use the Classical Probability Model: $P(E) = \frac{N(E)}{N(S)}$ with $N(S) = 2^{100}$

<I don't understand why it is $2^{100}$. Why isn't it just 100? >

So $P(E) = \frac{100!}{50!50!} \times 2^{-100}$

<Again, I don't get why we're using the combination formula? Why isn't it just $\frac{50}{100}$...????>

Can someone please explain this to me?
• September 29th 2009, 10:30 PM
noname
For the first question you should use the binomial distribution with n = 100, k = 50 and p = 1/2

n is the number of bernoulli trial
k is the number of success
p is the probability of success on a single trial, it's always the same because the outcome of every trial is independent from the others

Hint: if n is even you can write it m*2
• September 30th 2009, 02:06 PM
awkward
Quote:

Originally Posted by gconfused
Hi, well I'm totally lost with this subject, and this is an easy question but I just don't understand ..
Question: A fair coint is flipped n = 100 times. What is the probability to have exactly k = 50 heads? What is the probability to have exactly n/2 heads when n is even?

Use the Classical Probability Model: $P(E) = \frac{N(E)}{N(S)}$ with $N(S) = 2^{100}$
<I don't understand why it is $2^{100}$. Why isn't it just 100? >
So $P(E) = \frac{100!}{50!50!} \times 2^{-100}$
<Again, I don't get why we're using the combination formula? Why isn't it just $\frac{50}{100}$...????>
If you flip a coin 100 times and write down the outcome of each flip, there are $2^{100}$ possible sequences, each of which is equally likely. How many of those have exactly 50 heads? Exactly as many as there are ways to pick 50 flips out of the sequence of 100, i.e., the number of combinations of 100 objects taken 50 at a time, $\binom{100}{50} = \frac{100!}{50! \; 50!}$.


text:
## Volatility Is Above 2008 High Levels As Dow Jones Industrial Average Has 2nd Worst Percentage Decline

This is just a short post to document something remarkable.

Volatility is actually above 2008’s high levels.

With the Dow Jones Industrial Average (DIA) posting is second worst percentage decline ever, and a cluster of recent days on the worst performing days list, perhaps the jump in volatility amid the COVID-19 pandemic should not be a surpise.

Adding to the narrative, the S&P 500 Index (SPY) posted its third worst percentage decline day ever.

Ultimately, volatility is opportunity, and this elevated volatility will not be around forever. Thus, I think market participants should be making their shopping lists for what to own on the long side.


text:
If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

# Add and subtract within 20: FAQ

## How can we use place value blocks to help add and subtract?

We can use place value blocks to represent each number we want to add, and then combine them to find the total.
For example, if we want to add start color #0c7f99, 12, end color #0c7f99, plus, start color #ca337c, 6, end color #ca337c, we can start by drawing start color #0c7f99, 12, end color #0c7f99 blocks and then make a second group of place value blocks that has start color #ca337c, 6, end color #ca337c blocks. After we put them together, we will see there are 18 blocks.
An image of one tens rod and two ones blocks in one color and six ones blocks in another color.
For subtraction, we can use the blocks to represent the larger number, and then take away the appropriate number of blocks to find the difference.
For example, to subtract start color #0c7f99, 14, end color #0c7f99, minus, start color #ca337c, 8, end color #ca337c, we can draw a set of blocks that has start color #0c7f99, 14, end color #0c7f99 place value blocks. Then we can take away start color #ca337c, 8, end color #ca337c place value blocks from the start color #0c7f99, 14, end color #0c7f99 blocks. Now, there are 6 blocks lets.
An image of 14 place value blocks with 6 blocks crossed off.

## How can we use ten frames to help add and subtract?

Ten frames can be helpful for adding and subtracting because they allow us to visually see the numbers we're working with. To add using ten frames, we can fill in the frames with the numbers we want to add.
For example, if we want to add 8 and 4, we could fill in eight squares on one ten frame and four squares on another ten frame. By combining the two frames, we can see that the sum is 12.
There are two ten frames separated by a plus sign. The first ten frame has 8 dots. The second ten frame has 4 dots.
To subtract using ten frames, we can fill in the frame with the larger number and then remove squares to represent the smaller number. For example, if we want to subtract 3 from 7, we would fill in seven squares on the ten frame and then remove three squares. This would leave us with four squares filled in, which represents the difference.
One ten frame with 7 dots and 3 of the 7 crossed out.

## How can we use number lines to help add and subtract?

We can use the number line to visually represent the two numbers being added or subtracted. For example, to solve 7, plus, 9, we can mark both 7 and 9 on the number line. Then we can see that adding the two numbers together will result in a sum that falls between the two, at 16.
A number line beginning at 0 and ending at 20. An arrow from 0 to 7 has +7 above it. Another arrow from 7 to 16 has +9 above it.
To solve 12, minus, 4, mark 12 on the number line. Then we can subtract 4 to see that the jump ends at 8.
A number line beginning at 0 and ending at 20. A box is around the number 12. An arrow from 12 to 8 has -4 above it.

## How can we use arrays to help us add?

We can use arrays to represent repeated addition! For example, an array of 5 rows and 3 columns can be thought of as adding start color #0c7f99, 5, end color #0c7f99, start color #7854ab, start text, space, t, h, r, e, e, s, end text, end color #7854ab.
An array of pigs shows 5 rows and 3 columns.
start color #7854ab, 3, end color #7854ab, start superscript, start color #0c7f99, 1, end color #0c7f99, end superscript, plus, start color #7854ab, 3, end color #7854ab, start superscript, start color #0c7f99, 2, end color #0c7f99, end superscript, plus, start color #7854ab, 3, end color #7854ab, start superscript, start color #0c7f99, 3, end color #0c7f99, end superscript, plus, start color #7854ab, 3, end color #7854ab, start superscript, start color #0c7f99, 4, end color #0c7f99, end superscript, plus, start color #7854ab, 3, end color #7854ab, start superscript, start color #0c7f99, 5, end color #0c7f99, end superscript, equals, 15

## Where do we use addition and subtraction in the real world?

We use addition and subtraction all the time! For example, we might use them when we're counting money, dividing up snacks, or measuring ingredients for a recipe.

## Want to join the conversation?

• 3+3+3+3+3=15
• 15 is right
• How do you add 6+7 by using base 10 blocks?
• You can add 6 + 7 using base 10 blocks this way:

Imagine that you have 2 boxes, 1 with 6 balls and 1 with 7 balls. You need to put 3 bolls in the 2nd box to make 10 on that box. So, you take 3 from the 1st box and put them on the 2nd box.

(6) + (7) =
(3 + 3) + 7 =
(3) + (3 + 7) =
(3) + (10) =
(13)
• karskilaru if you dont know what to do just ask for help i can help u if u like its easy math i know how to do it afterall im in 5th grade. :)
• 90+90
• The answer of 90+90 is 180. This could also be 90x2.
• code
• I meant I’m going to 6th grade so I’m in 5th grade


text:
# Quasiparticles in Bohmian mechanics

My questions are about de Broglie-Bohm "pilot wave" interpretation of quantum mechanics (a.k.a. Bohmian mechanics).

1. Do quasiparticles have any meaning in Bohmian mechanics, or not? Specifically, is it possible to trace the motion of a quasiparticle (e.g. a phonon, or a hole) by watching Bohmian trajectories?

2. Bohmian mechanics provides some explanation of difficulties related to quantum measurement process. But imagine that, in some kind of "theory of everything", all known elementary particles (leptons, quarks, gluons etc.) are actually quasiparticles (real particles are always confined). Would the explanation, provided by Bohmian mechanics, survive in this case?

-
I think that your inherent suggestion that the Bohmian mechanics suffers from an inconsistency because of quasiparticles is right. QM shows that it doesn't matter whether one says that something is a particle or quasiparticle: the Hilbert spaces and dynamics and probabilistic predictions are isomorphic. In the Bohmian mechanics, it always matters because particles' degrees of freedom are "beable" while other e.g. quasiparticles' degrees of freedom are not. For the same reason, quantum computers can't simulate the reality in Bohmian mechanics. It just doesn't work. –  Luboš Motl Oct 6 '11 at 12:03
@Luboš Motl: Electron (a particle) in Hydrogen atom is always in a mixed state - it does not have an electron wave function $\psi (\vec{r}_e)$. Instead, it is a quasi-particle that may be in a pure state $\psi (\vec{r})$ where $\vec{r}=\vec{r}_e-\vec{r}_p$. As well, proton is also in a mixed state but the center of mass may be in a pure state like $exp\left ( i(\vec{P}\vec{R}-\frac{P^2}{2M_A\hbar}t)\right)$.There are no such real particles with $\mu$ and $M_A=m_e+m_p$; the corresponding variables describe quasi-particles. It is namely quasi-particle energy in atom that is quantized. –  Vladimir Kalitvianski Oct 6 '11 at 13:13
The answer to your question, @Vladimir, is obviously No: every quantum system (whether it is a particle or quasiparticle) may always be found in a pure state. That's why any quantum system may exhibit 100% destructive interference etc., something that would indeed be impossible if an object were "forced" to be partly mixed, and this is one reason why any picture of the quantum phenomena that tries to be more classical than QM (including Bohmian mechanics) is inevitable inconsistent with the tests of interference and other empirically established features of the quantum world. –  Luboš Motl Oct 6 '11 at 15:57
What do you mean by "meaning"? How can you say that quasiparticles have any meaning in standard quantum mechanics? They're just a very good way of describing an emergent phenomenon; they don't really exist in the usual sense of the word. –  Peter Shor Oct 8 '11 at 21:27
Can I also say that after thinking it over, I suspect there may be a very good question lurking in here. Namely: do the trajectories of quasiparticles in Bohmian mechanics obey the same rules as the trajectories of particles in Bohmian mechanics? And if not, what rules do they obey? –  Peter Shor Oct 10 '11 at 22:21


text:
# SET

Bulk Data Entry Defines a set of grids, elements, design variables, MBD entities, mode numbers, frequencies or times for reference by other input definitions.

## Format

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET SID TYPE SUBTYPE/

OPERATOR

ID1/

MODE1/

REAL1/

NAME1/

SID1/

X1/

G1/

ALL

ID2/

MODE2/

REAL2/

NAME2/p/

Y1

ID3/

MODE3/

REAL3/

NAME3/

SID3/

Z1

ID4/

MODE4/

REAL4/

NAME4/

SID4/

X2/

G2

ID5/

MODE5/

REAL5/

NAME5/

SID5/

Y2

ID6/

MODE6/

REAL6/

NAME6/

SID6/

Z2

ID7/

MODE7/

REAL7/

NAME7/

SID7

ID8/

MODE8/

REAL8/

NAME8/

SID8

ID9/

MODE9/

REAL9/

NAME9/

SID9

etc. etc. etc. etc. etc. etc. etc.
etc. etc.

## Alternate Format for ID Ranges

(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET SID TYPE SUBTYPE
ID1 THRU ID2 EXCEPT ID3 ID4 ID5 ID6
ID7 etc. ENDTHRU
etc.

## Example 1

The following set contains the grids 1, 17, 22, 23, 29, 33, 35, 48, 88, 93 and 102. It is defined using a simple ID list (assuming that these GRID cards are present in the Bulk Data).
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET 56 GRID LIST
88 93 17 1 23 29 35 48
33 102 22

## Example 2

The following set contains the elements 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 33, 34, 34, 35, 36, 37, 38, 41, 42, 43, 44, 45, 94, 95, 96. 97, 98, 99, 106, 107, 108, 109, 110, 111, 120, 121 and 125. It is defined using a combination of ID ranges and lists.
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET 56 ELEM LIST
11 THRU 22
33 THRU 45 EXCEPT 39 40
94 THRU 111 EXCEPT 100 101 102 103
104 105 ENDTHRU
120 121 125

## Example 3

The following set includes any element included in sets 29, 30 or 31. It is defined as Boolean set.
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET 50 ELEM OR
29 30 31

## Example 4

The following set defines GRID/Component list; intended for use by PFMODE.
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET 11 GRIDC
12 T1 15 R2 128 T3

## Example 5

The following set defines list of strings.
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET 11 LABEL
LABEL1 LABEL2 TOP UPPER LOWER LEFT

## Example 6

The following set defines list of all elements with specific properties.
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET 11 ELEM PROP EXCEPT PHSELL
1 12 15 thru 128 555

## Example 7

The following set outputs all of the grids on PLOTEL.
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
SET ID GRID ELTYPE
PLOTEL

## Definitions

Field Contents SI Unit Example
SID Unique set identification. 1
Integer
Specifies an identification number for the set.
<String>
Specifies a user-defined string label for the set. 2

No default (Integer > 0 or <String>)

TYPE Identifies what type of entities the set is comprised of. 3
GRID
ELEM
RIGID
GRIDC
DESVAR
MODE
FREQ
TIME
LABEL
PLY

No default

SUBTYPE Indicates how the set is defined. 3
LIST (Default)
BBOX
PROP
MAT
ELTYPE
ELEM
DMIG

OPERATOR Operators supported in defining Boolean sets. 5 6 7
OR
AND
NOT
MINUS

No default

ID# ID list. Only valid for certain combinations of TYPE and SUBTYPE. The entity to which the ID corresponds depends on the TYPE and SUBTYPE of the set. 3

ID ranges may be used in combination with ID lists. The keywords EXCEPT and THRU are used to define ID ranges. The keyword ENDTHRU identifies the end of an ID range and is required if an ID list is to follow where the first value is within the previous range.

ID lists following EXCEPT must be in ascending order and must exist within the previous range.

No default (Integer > 0)

MODE# Mode number list. Only valid when TYPE is MODE. 3

Mode number ranges may be used in combination with Mode number lists. The same rules apply as for ID ranges.

No default (Integer ≥ 0) 11

REAL# Real value list. Only valid when TYPE is FREQ or TIME. 3

No default (Real)

NAME# Keyword list. Only valid for certain combinations of TYPE and SUBTYPE.

The keyword EXCEPT is allowed only as the first entry in a keyword list.

Default = Undefined 3

SID# Identification number of another SET definition. Used in defining Boolean sets. Only valid when OPERATOR is defined in SUBTYPE/OPERATOR field 5 6 7 8

No default (Integer > 0 or <PartName.number>)

X1, Y1, Z1, X2, Y2, Z2 X, Y, and Z coordinates of two opposing corners of a cuboid. Only valid when SUBTYPE is BBOX 3

No default (Real)

G1, G2 Grid ID's (G1, G2) can be used instead of (X1, Y1, Z1), (X2, Y2, Z2) data (see field descriptions above). G1, G2 should be defined in the basic coordinate system (CP field on the GRID entries should be blank).
ALL Keyword used for ID lists to indicate that all IDs of the appropriate entity type are to be included in the set.

Only valid in first field of ID list.

May be followed by keyword EXCEPT (see below).

THRU Keyword used for ID ranges to indicate that all IDs between the preceding ID and the following ID are to be included in the set.

Definition of range may contain list of exceptions in the following form:

N1 THRU N2 EXCEPT N3 N4 ... ENDTHRU

where, N1 ≤ N3 < N4... ≤ N2; N1 < N2

EXCEPT Keyword used for ID ranges and keyword lists to indicate that the following IDs or keywords are to be excluded from the set.

Only valid in first field for keyword lists.

When ALL is given as the first entry for an ID list, EXCEPT may be given as the second entry, in which case all subsequent IDs are excluded from the set of ALL entities of the defined TYPE.

ENDTHRU Optional keyword used after EXCEPT to indicate the end of an excluded ID list definition.

1. SID must be unique with respect to all other SET definitions (regardless of type). It must also be unique with respect to any SURF entries and any legacy SET/PSET I/O Options definitions.
2. String based labels allow for easier visual identification of sets, including when being referenced by other cards. (For example, the GSETID field in SPC). For more details, refer to String Label Based Input File in the Bulk Data Input File.
3. The following table describes subtype combinations and the set TYPE's for which they are valid.
TYPE SUBTYPE Description
GRID LIST or undefined This is a set of grids - structural grids (GRID) or scalar points (SPOINT) - defined either as a simple list of grid IDs, or as some combination of ranges of grid IDs and lists of grid IDs.
BBOX This is a set of grids defined by a bounding box. The fields X1, Y1, and Z1 provide the coordinates of one corner and X2, Y2, and Z2 the coordinates of an opposing corner of a cuboid. All grids contained within this cuboid are included in the set.

The bounding box can also be defined using the G1 and G2 fields instead of (X1, Y1, and Z1) and (X2, Y2, and Z2), respectively.

ELEM This is a set of structural grids (GRID) belonging to listed elements.
DMIG This is a set of grids belonging to the listed DMIG(‘s). DMIG's can either be listed by name (in the NAME# fields), or using the flag ALL (this would select grids of all DMIG’s).
ELEM LIST or undefined This is a set of elements defined either as a simple list of element IDs, or as some combination of ranges of element IDs and lists of element IDs.
BBOX This is a set of elements defined by a bounding box. The fields X1, Y1, and Z1 provide the coordinates of one corner and X2, Y2, and Z2 the coordinates of an opposing corner of a cuboid. All elements whose centroids are contained within this cuboid are included in the set.

The bounding box can also be defined using the G1 and G2 fields instead of (X1, Y1, and Z1) and (X2, Y2, and Z2), respectively.

PROP This is a set of elements defined in one of the following ways:
1. Through a list of property IDs, or some combination of ranges of property IDs and lists of property IDs. If multiple properties have the same ID (as PBAR may), they are all considered. All elements referencing the selected properties are included in the set.
2. Through a list of property types. All elements referencing properties of the listed type (PBAR, PCOMP, PSHELL, and so on) are included in the set.
3. Through a list of excluded property types. All elements except those referencing properties of the listed type, following the keyword EXCEPT, are included in the set.
4. List of property types or list of excluded property types may be followed by some combination of ranges of property IDs and lists of property IDs. All elements referencing properties satisfying both requirements (type and ID) are included in (or accepted from) the set.
MAT This is a set of elements defined through a list of material IDs, or some combination of ranges of material IDs and lists of material IDs. All elements referencing properties, that in turn reference the selected materials, are included in the set.
ELTYPE This is a set of elements defined in one of the following ways:
1. Through a list of element types. All elements of the listed type (CQUAD4, CHEXA, CBEAM, and so on) are included in the set.
2. Through a list of excluded element types. All elements except those of the listed type, following the keyword EXCEPT, are included in the set.
In addition to all valid element types, the following element type groupings may be used:
SOLID
For CTETRA, CPYRA, CPENTA and CHEXA elements referencing structural property definitions.
FLAT
SHELL
For FLAT elements referencing properties with non-zero MID2.
MEMBRANE
For FLAT elements referencing properties with zero MID2.
BEAM
For CBAR and CBEAM elements.
ROD
For CONROD and CROD elements.
FLUID
For CTETRA, CPYRA, CPENTA and CHEXA elements referencing fluid property definitions.
For rigid elements (RROD, RBAR, RBE1, RBE2 and RBE3). See RIGID below.
DMIG This is a set of elements belonging to the listed DMIG(‘s). DMIG’s can either be listed by name (in the NAME# fields), or using the flag ALL (this would select elements of all DMIG’s).
RIGID LIST or undefined This is a set of rigid elements defined either as a simple list of rigid element IDs, or as a combination of ranges of rigid element IDs and lists of rigid element IDs.
GRIDC LIST or undefined This is a set of GRID/Component pairs.
DESVAR LIST or undefined This is a set of design variables defined either as a simple list of design variable IDs, or as some combination of ranges of design variable IDs and lists of design variable IDs.
MODE LIST or undefined This is a set of mode numbers defined as a simple list of mode numbers, or as some combination of ranges of mode numbers and lists of mode numbers.

This can also reference a list of RANDPS Bulk Data Entry IDs. Such a SET Bulk Data Entry can be referenced by the RANDOM Subcase Entry.

FREQ LIST or undefined This is a set of real values representing frequencies defined simply as a list of real values.
TIME LIST or undefined This is a set of real values representing times defined simply as a list of real values.
LABEL LIST or undefined List of arbitrary labels. Each label must start with a letter and contain only letters or digits.
PLY LIST or undefined This is a set of ply ID's defined in the PLY or PCOMPG Data Entries.
4. SET definitions using may refer to non-existing entities. This is allowed, but the actual SET will contain only grids or elements which are present in the structure.
5. The Boolean operators OR, AND, NOT and MINUS are recognized for SET combinations.
Operator
Description
OR
An entity is included in the SET, if it is included in a minimum of one of the constituent sets. OR is used to expand the SET by combining items from various SET's (for example, an entity is included in SET, if it is present in SET1, SET2, or SET3, or ...).
AND
An entity is included in the SET, if it is included in all of the listed sets. AND is used to restrict the SET to a typically smaller subset (for example, an entity is included in SET, if it is present in SET1, SET2, and SET3, and ...).
NOT
An entity is included in the SET, if it is not included in the listed set (for example, if an entity is not included in SET 1, then it is included in SET).
Note: Only one set should be listed for the NOT operator.
MINUS
An entity is included in the SET if it is included in the first set, but not in the second set.
Note: Only two sets may be listed for when this operator is used.
6. Boolean SET definitions can only be used when all listed sets are of the same TYPE.
7. Boolean SET definitions can reference other Boolean sets, but circular references must be avoided. Boolean SET can be defined only for GRID, ELEM, or RIGID set types.
8. Supported local entries in specific parts can be referenced by the use of "fully-qualified references" on SET entries in the model. A fully-qualified reference (PartName.number) is similar to the format of a numeric reference. PartName is the name of the part that contains the referenced local entry (part names are defined on the BEGIN Bulk Data Entry in the model). number is the identification number of a referenced local entry in the part PartName. See Parts and Instances in the User Guide for detailed information on the use of fully-qualified references.

The SET Bulk Data Entry can be used in the global part to reference SET's defined within different parts. These SET entries in the global part can contain fully qualified references to part-specific SET data only if logical operators (OPERATOR field) are used. For example:

The following SET entry exists in part A:
BEGIN, FEMODEL, A
SET, 29, ELEM, LIST
15 THRU 30
...END, FEMODEL, A
Referencing SET, 29 in the global part G:
BEGIN, FEMODEL, G
SET, 78, ELEM, OR
A.29
...
END, FEMODEL, G
9. ELIST is an alternative to SET and SURF, but ELIST is intended only to provide compatibility with Nastran decks. It is recommended to use SURF/SET, instead of ELIST. Additionally,
• The SURF and SET entries may not be combined with ELIST entries to define damp elements.
• ELIST entries are internally converted to SET entries. If ELIST is referenced on a minimum of one MFLUID entry, then all MFLUID entries in a model must reference ELIST entries. In such cases, if an MFLUID entry references a particular Set Identification Number (<SID>) to define WSURF1/WSURF2 fields without a corresponding ELIST,<SID> in the model, then OptiStruct will not search for a SET/SURF,<SID>.
10. K2GG, M2GG, K42GG, B2GG, K22GGSUB, M2GGSUB, and B2GGSUB can reference SET of labels. Only one set can be referenced on each of these entries, but multiple such entries are supported.
11. In cyclic symmetry analysis, SET with TYPE = MODE can be used to specify the solution harmonic indices by referencing the SET in the HARMONICS I/O Options Entry, or the segment indices by referencing the SET in the NOUTPUT I/O Options Entry, where each mode number corresponds to a harmonic or segment index. Mode number of 0 is meaningful only for HARMONICS in cyclic symmetry analysis.
12. This card is represented as a set in HyperMesh.


text:
+1 vote
908 views

In propositional logic, given P and P $\rightarrow$ Q, we can infer ____

1. $\sim$ Q
2. Q
3. P $\wedge$ Q
4. $\sim$ P $\wedge$ Q
in Others
retagged | 908 views

P -> Q  ans P infer to Q
Using : Modus Ponens

by Veteran (62.5k points)
P  -> Q   = ~P  V Q

So we can infer Q

by Boss (32.2k points)
edited by
+1 vote
if P then Q

P is given so we can infer Q
by Boss (48.5k points)

Ans: B

• Whenever E is a tautology, P1 AND P2 AND .. Pn -> E is a tautology.
• Given two premises P1 and P2, we can infer P1 AND P2.
• If P1 and (P1 -> P2) are given or inferred, then we can infer P2 by the rule of modus ponens (p AND (p->q) -> q).
• If NOT P2 and (P1 -> P2) are given or inferred, then we can infer NOT P1 by the rule of modens tollens.
• If P1 and (P1==P2) are given or inferred, we can infer P2.
by Loyal (7.1k points)

+1 vote
1
2


text:
# Using Midpoint and Distance Formulas

Midpoint and distance formulas are important tools used in mathematics to calculate the location of points and the length of lines. The midpoint formula, which finds the center point between two points, and the distance formula, which finds the length of a line between two points, are both simple to use and easy to remember.

## What is the Midpoint Formula?

The midpoint formula is used to find the midpoint of a line segment that connects two points. This formula uses the coordinates of the two points to calculate the coordinates of the midpoint. The midpoint formula is written as: M = (x1 + x2 / 2, y1 + y2 / 2). The M stands for the coordinates of the midpoint, and the x1 and x2 stand for the x-coordinates of the two points, with y1 and y2 standing for the y-coordinates of the two points.

## What is the Distance Formula?

The distance formula is used to calculate the length of a line segment between two points. This formula uses the coordinates of the two points to calculate the distance between them. The distance formula is written as: d = √ (x2 – x1)2 + (y2 – y1)2. The d stands for the distance, and the x1 and x2 stand for the x-coordinates of the two points, with y1 and y2 standing for the y-coordinates of the two points.

## How to Use Midpoint and Distance Formulas

To use the midpoint and distance formulas, you need to have the coordinates of the two points that you want to calculate the distance between or the midpoint of. Once you have the coordinates, you can simply plug them into the formulas to calculate the midpoint or the distance. It is important to remember that the midpoint formula only works with two points, but the distance formula can be used to calculate the distance between three or more points.

## Why Midpoint and Distance Formulas are Important

Midpoint and distance formulas are important tools used in mathematics and other fields. These formulas are used to calculate the location of points and the length of lines, making them useful for finding distances between points on a map, calculating the area of a triangle, or finding the center of a circle. They are also important for finding the equation of a line between two points, calculating the perimeter of a shape, and finding the slope of a line.

##

Midpoint and distance formulas are essential tools used in mathematics and other fields. They can be used for a variety of calculations, including finding the midpoint between two points, calculating the distance between two points, finding the equation of a line between two points, and calculating the perimeter of a shape. With these formulas, it is easy to calculate the location of points and the lengths of lines.


text:
# How to write this simple task of unimodular prime search in mathematica?

For testing a particular algorithm I found mathematica is the best way as it has all the tools I need. I am stuck in a number theory part and since I am not an expert in mathematica I do not know how to write a code that seemingly involves loops. I want to pick random integers $$a,b$$ in interval $$[T,2T]$$ at $$T>0$$ and obtain $$u,v\in\mathbb Z$$ such that

1. $$au-bv=1$$ (Euclidean algorithm)

2. $$au+bv$$ is a prime

3. $$GCD(ab,uv)=1$$

4. $$0

holds.

Is there simple enough code to do this?

It would help me to have 5. $$a,b,u,v$$ are all prime integers.

• You realize there will very likely be an infinite number of such $u,v$ pairs? Or is just one instance enough? I suggest using the FindInstance[] function without any loops. – Somos Oct 11 at 18:30
• There are so many conditions. If I know correct a and b find instance will work. Or else it is quadratic diophantine. – a.. Oct 11 at 22:22
• I think this is misworded. In general such u,v need not exist. Are you wanting code that will keep picking random a,b until you get a pair for which they do exist? – Daniel Lichtblau Oct 12 at 13:40
• @DanielLichtblau Exactly. It appears mathematica is not very straightforward with procedural programming with loops. – a.. Oct 12 at 14:17
• (1) The coding is straightforward. One just needs to know the parameters of the problem. That is, are all of a,b,u,v sought or just, as it was worded, u and v? (2) Loops, should you wish to use them explicitly, can be accomplished with any of For, Do, and While. Same as in other languages. – Daniel Lichtblau Oct 12 at 14:44

primeVectors[max_, tries_] := Catch[Module[
{a, b, done = False, tt = 0, u, v, egcd},
While[! done && tt < tries,
tt++;
{a, b} = RandomInteger[{2, max}, 2];
egcd = ExtendedGCD[a, b];
If[egcd[[1]] =!= 1, Continue[]];
{u, v} = {1, -1}*egcd[[2]];
If[u < 0,
{u, v} = {u, v} + {b, -a}; If[u < 0, Continue[]]];
If[(! PrimeQ[a*u + b*v] || GCD[a*b, u*v] =!= 1), Continue[],
Throw[{{a, b}, {u, v}}]]
];
$Failed ]] examples: SeedRandom[1234] Table[primeVectors[1000, 15], 10] (* Out[2247]= {{{899, 664}, {243, 329}}, $$Failed, {{544, 695}, {359, -807}},$$Failed,$Failed, {{215,
571}, {409, -276}}, {{79, 347}, {123, 28}}, {{313, 555}, {172,
97}}, {{581, 155}, {151, -596}}, {{395, 313}, {42, 53}}} 7} *)
• This is a bit complicated as I am seeing for first time. So this address 1,2 and 4? – a.. Oct 12 at 20:14
• With "PrimeQ[au + bv] || GCD[ab, uv] =!= 1" seems address all of 1,2,3 and 4. Correct? – a.. Oct 12 at 20:14
• Yes, all four are addressed – Daniel Lichtblau Oct 12 at 20:31
• May I ask how $a,b$ in $[T,2T]$ is guaranteed? I need a, b} = {a,b}=RandomInteger[{T,2T},2] correct? – a.. Oct 13 at 20:22
• I used max for your T. So they are selected to be less. If you want them in [T,2T] then that random generation needs to be modified slightly. – Daniel Lichtblau Oct 13 at 21:35


text:
# [C++] Direct3D hooking sample

This topic is 2901 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Wow! This is really cool!
You should make this an article =P

[Edited by - DirectXFreak on November 28, 2005 5:07:07 PM]

##### Share on other sites
Quote:
 Original post by PromitMaybe I'm missing something here, but isn't that exactly what PIX does?

D'oh...

I just tried that using PIX on GTA: San Andreas. Some sample stats:

DrawPrim............32DrawIndexedPrim.....160VB Locks............45IB Locks............13SetRenderState......163SetTexture..........190SetVertexShader.....6SetPixelShader......0SetRenderTarget.....12

Considering that this was a really simple scene (just inside the main characters house, very low complexity) I think those numbers are high.

##### Share on other sites
Quote:
 Original post by PromitMaybe I'm missing something here, but isn't that exactly what PIX does?

Yeah, essentially... I have to admit I haven't tried it, but you can't get PIX to generate an overdraw of the image, can you? deep pixel analysis yes, but not shader complexity and so on..?

The idea came from this thread. It'd be pretty awesome if you could somehow display the number of pixel shader arithmetic or texture instruction count per-pixel. Could make for a great performance debugging tool - the brighter the colours the more fill-rate related work you're doing etc...

Then again, hacking that in via hooking stands as much chance of breaking things as it does working [lol]

Oh, and the obvious advantage is that it'd be overlayed - giving immediate feedback rather than the capture full stream then analyse the data.

Jack

##### Share on other sites
Why might you need that many VB and IB locks per frame?
Was there a legendary particle system in the house or something?

##### Share on other sites
Quote:
 Original post by DrGUIWhy might you need that many VB and IB locks per frame?Was there a legendary particle system in the house or something?

Yea, and this is inside a really simple house. I did some more investigating, and profiled a complex scene outside:

DIP Calls:  1300 - 2300 (:O !!!)VB Locks: 120-145IB Locks: 50-75New VBs: 1-5New IBs: 1-7FPS: 10-20

Yea...so I wonder really what the frick is going on. Looks like someone at Rockstar needs to read the renown instancing slidedeck...

##### Share on other sites
If I use that sample than AOE 3 hangs.
And nothing happened in COD 2.

##### Share on other sites
Oh my. This could be used for some serious hacking of applications. Really, you could trace exactly how the api is used - frankly I think it is pretty cool but I am surprised that MS allows this type of thing to be done.

I think I am going to try a few experiments with my own engine and see if this can be used for some type of runtime analysis of my rendering calls. Great work, I appreciate your effort (and typing abilities!).

##### Share on other sites
Quote:
 Original post by Jason ZOh my. This could be used for some serious hacking of applications. Really, you could trace exactly how the api is used - frankly I think it is pretty cool but I am surprised that MS allows this type of thing to be done.

I think so, since they full support the ultimate "hacking" application - PIX. PIX makes it easy to analyze exactly what an application is doing, D3D-wise. IMO, after doing some trials on commercial games, it is more helpful than the hooking approach for profiling.

##### Share on other sites
Holy Crap!

I just ran a test run of PIX on the latest build of my game. I tried using PIX long ago when it first came out and wasn't very impressed, but it has really evolved quite a bit from what I remember.

The object window alone is worth using, not to mention the frame rendering stream. So this will work with any D3D9 commercial application? I guess once you ship something you are essentially allowing everyone to see what you are doing - it kind of opens up the doors to smaller developers (like me!) to see what the big boys are doing.

Thats pretty cool.

##### Share on other sites
Quote:
 Original post by Jason ZThe object window alone is worth using, not to mention the frame rendering stream. So this will work with any D3D9 commercial application? I guess once you ship something you are essentially allowing everyone to see what you are doing - it kind of opens up the doors to smaller developers (like me!) to see what the big boys are doing.

Yea pretty much - they have worked on all commercial games I have tried it on (HL2, Farcry, GTA:SA). If you read a few posts above, I show some figures about GTA that are a little disturbing [crying]

• 10
• 18
• 11
• 14
• 10


text:
12 Hoshen Gems

The priestly breastplate ( Hebrew : חֹשֶׁן ẖošen) was a sacred breastplate worn by the High Priest of the Israelites, according to the Book of Exodus.

These stones were, at times, used to determine God's will in a particular situation (see Exodus 28:30).

According to kabbalah and ancient philosophy, ‘all powers can be found in the derivatives of all gems that matches these powers to the characteristics of their corresponding tribes.

Each Shammaim  machine consists the Hosen stones.


text:
# Dft definition and properties

 Page 1 / 1
The discrete Fourier transform (DFT) and its inverse (IDFT) are the primary numerical transforms relating time and frequency in digital signal processing. The DFT has a number of important properties relating time and frequency, including shift, circular convolution, multiplication, time-reversal and conjugation properties, as well as Parseval's theorem equating time and frequency energy.

## Dft

The discrete Fourier transform (DFT) is the primary transform used for numerical computation in digital signal processing. It is very widely used for spectrum analysis , fast convolution , and many other applications. The DFT transforms $N$ discrete-time samples to the same number of discrete frequency samples, and is defined as

$X(k)=\sum_{n=0}^{N-1} x(n)e^{-(i\frac{2\pi nk}{N})}$
The DFT is widely used in part because it can be computed very efficiently using fast Fourier transform (FFT) algorithms.

## Idft

The inverse DFT (IDFT) transforms $N$ discrete-frequency samples to the same number of discrete-time samples. The IDFT has a form very similar to the DFT,

$x(n)=\frac{1}{N}\sum_{k=0}^{N-1} X(k)e^{i\frac{2\pi nk}{N}}$
and can thus also be computed efficiently using FFTs .

## Periodicity

Due to the $N$ -sample periodicity of the complex exponential basis functions $e^{i\frac{2\pi nk}{N}}$ in the DFT and IDFT, the resulting transforms are also periodic with $N$ samples.

$X(k+N)=X(k)$ $x(n)=x(n+N)$

## Circular shift

A shift in time corresponds to a phase shift that is linear in frequency. Because of the periodicity induced by the DFT and IDFT, the shift is circular , or modulo $N$ samples.

$(x((n-m)\mod N), X(k)e^{-(i\frac{2\pi km}{N})})$ The modulus operator $p\mod N$ means the remainder of $p$ when divided by $N$ . For example, $9\mod 5=4$ and $-1\mod 5=4$

## Time reversal

$(x(-n\mod N)=x((N-n)\mod N), X((N-k)\mod N)=X(-k\mod N))$ Note: time-reversal maps $(0, 0)$ , $(1, N-1)$ , $(2, N-2)$ , etc. as illustrated in the figure below.

## Complex conjugate

$(\overline{x(n)}, \overline{X(-k\mod N)})$

## Circular convolution property

Circular convolution is defined as $\doteq ((x(n), h(n)), \sum_{m=0}^{N-1} x(m)x((n-m)\mod N))$

Circular convolution of two discrete-time signals corresponds to multiplication of their DFTs: $((x(n), h(n)), X(k)H(k))$

## Multiplication property

A similar property relates multiplication in time to circular convolution in frequency. $(x(n)h(n), \frac{1}{N}(X(k), H(k)))$

## Parseval's theorem

Parseval's theorem relates the energy of a length- $N$ discrete-time signal (or one period) to the energy of its DFT. $\sum_{n=0}^{N-1} \left|x(n)\right|^{2}=\frac{1}{N}\sum_{k=0}^{N-1} \left|X(k)\right|^{2}$

## Symmetry

The continuous-time Fourier transform , the DTFT , and DFT are all defined as transforms of complex-valueddata to complex-valued spectra. However, in practice signals are often real-valued.The DFT of a real-valued discrete-time signal has a special symmetry, in which the real part of the transform values are DFT even symmetric and the imaginary part is DFT odd symmetric , as illustrated in the equation and figure below.

$x(n)$ real  $X(k)=\overline{X((N-k)\mod N)}$ (This implies $X(0)$ , $X(\frac{N}{2})$ are real-valued.)

where we get a research paper on Nano chemistry....?
what are the products of Nano chemistry?
There are lots of products of nano chemistry... Like nano coatings.....carbon fiber.. And lots of others..
learn
Even nanotechnology is pretty much all about chemistry... Its the chemistry on quantum or atomic level
learn
da
no nanotechnology is also a part of physics and maths it requires angle formulas and some pressure regarding concepts
Bhagvanji
Preparation and Applications of Nanomaterial for Drug Delivery
revolt
da
Application of nanotechnology in medicine
what is variations in raman spectra for nanomaterials
I only see partial conversation and what's the question here!
what about nanotechnology for water purification
please someone correct me if I'm wrong but I think one can use nanoparticles, specially silver nanoparticles for water treatment.
Damian
yes that's correct
Professor
I think
Professor
Nasa has use it in the 60's, copper as water purification in the moon travel.
Alexandre
nanocopper obvius
Alexandre
what is the stm
is there industrial application of fullrenes. What is the method to prepare fullrene on large scale.?
Rafiq
industrial application...? mmm I think on the medical side as drug carrier, but you should go deeper on your research, I may be wrong
Damian
How we are making nano material?
what is a peer
What is meant by 'nano scale'?
What is STMs full form?
LITNING
scanning tunneling microscope
Sahil
how nano science is used for hydrophobicity
Santosh
Do u think that Graphene and Fullrene fiber can be used to make Air Plane body structure the lightest and strongest. Rafiq
Rafiq
what is differents between GO and RGO?
Mahi
what is simplest way to understand the applications of nano robots used to detect the cancer affected cell of human body.? How this robot is carried to required site of body cell.? what will be the carrier material and how can be detected that correct delivery of drug is done Rafiq
Rafiq
if virus is killing to make ARTIFICIAL DNA OF GRAPHENE FOR KILLED THE VIRUS .THIS IS OUR ASSUMPTION
Anam
analytical skills graphene is prepared to kill any type viruses .
Anam
Any one who tell me about Preparation and application of Nanomaterial for drug Delivery
Hafiz
what is Nano technology ?
write examples of Nano molecule?
Bob
The nanotechnology is as new science, to scale nanometric
brayan
nanotechnology is the study, desing, synthesis, manipulation and application of materials and functional systems through control of matter at nanoscale
Damian
Is there any normative that regulates the use of silver nanoparticles?
what king of growth are you checking .?
Renato
What fields keep nano created devices from performing or assimulating ? Magnetic fields ? Are do they assimilate ?
why we need to study biomolecules, molecular biology in nanotechnology?
?
Kyle
yes I'm doing my masters in nanotechnology, we are being studying all these domains as well..
why?
what school?
Kyle
biomolecules are e building blocks of every organics and inorganic materials.
Joe
how did you get the value of 2000N.What calculations are needed to arrive at it
Privacy Information Security Software Version 1.1a
Good
Berger describes sociologists as concerned with
what is hormones?
Wellington
Got questions? Join the online conversation and get instant answers!


text:
Microlibrary finding all common subsequences between two sequences in polynomial time.

## Project description

A re-usable Python micro-library that finds all of the subsequences shared between two sequences (like strings or lists) in polynomial time.

(c) A. Samuel Pottinger (http://gleap.org), 2013 Released under the [MIT license](http://opensource.org/licenses/MIT). Don’t forget to be awesome.

## Installation (pip)

pip install py_common_subseq

## Installation (manual / single file)

This mico-library is a single file and engineers that may prefer to include the file directly instead of using pip can simply copy py_common_subseq/py_common_subseq.py into an accessible location. This micro-library does not have any additional dependencies beyond the Python standard library.

## Quickstart

 >>> import py_common_subseq >>> test_seq_1 = 'qwer' >>> test_seq_2 = 'qewr' >>> py_common_subseq.count_common_subsequences(test_seq_1, test_seq_2) 12 >>> py_common_subseq.find_common_subsequences(test_seq_1, test_seq_2) set(['', 'qer', 'wr', 'qwr', 'er', 'qr', 'e', 'qw', 'q', 'r', 'qe', 'w']) >>> py_common_subseq.find_common_subsequences(test_seq_1, test_seq_2, sep=',') set(['', ',q,w,r', ',e,r', ',e', ',w,r', ',q,w', ',q,r', ',w', ',r', ',q', ',q,e', ',q,e,r'])

## Full API

count_common_subsequences(seq_1, seq_2) Find the number of common subsequences between two collections.

This function finds the number of common subsequences between two collections but does not return an actual listing of those subsequences. This is more space efficient O(len(seq_1)) than find_common_subsequences.

• seq_1: Any integer indexable collection (list, tuple, etc.). The first collection to find subsequences in.

• seq_2: Any integer indexable collection (list, tuple, etc.). The second collection to find subsequences in.

• return: Integer. The number of common subsequences between seq_1 and seq_2.

find_common_subsequences(seq_1, seq_2) Find the number of common subsequences between two collections.

This function finds the common subsequences between two collections and returns an actual listing of those subsequences. This is less space efficient (O(len(seq_1)^2)) than count_common_subsequences.

• seq_1: Any integer indexable collection (list, tuple, etc.). The first collection to find subsequences in.

• seq_2: Any integer indexable collection (list, tuple, etc.). The second collection to find subsequences in.

• sep: Seperator to put between elements when constructing a subsequence. Keyword argument defaulting to ‘’.

• empty_val: The value to use to represent the empty set. Keyword argument defaulting to ‘’.

• return: Python standard lib set. Set of subsequences in common between seq_1 and seq_2.

## Motivation / Background

While the longest common subsequence allows for the comparison of sequences, some problem domains also benefit from the additional information hiding in the second, third, fourth, etc. largest common subsequences ignored by typical LCS. This micro-library provides an implementation of the dynamic programming solution for finding all common subsequences as presented in All Common Subsequences (http://dl.acm.org/citation.cfm?id=1625377 - calACS-DP) by Hui Wang (http://www.ulster.ac.uk/staff/h.wang.html). This micro-library also adds some space efficiency improvements and functionality to list common subsequences (semi-formal proof below).

## Testing

Within the py_common_subseq folder, run:

python test_py_common_subseq.py

Unit tests do not have any dependencies beyond the Python standard library.

## Overview of Space and Time complexity

The algorithm runs in O(|A|x|B|) time where |A| is the length of the first sequence provided and |B| is the length of the second sequence. Space complexity is as follows:

count_common_subsequences: 2 * min(len(seq_1), len(seq_2)) or O(min(|A|, |B|)) find_common_subsequences: 2 * min(len(seq_1), len(seq_2))^2 or O(min(|A|, |B|))^2

See the discussion below for additional detail.

## Overview of Deviations and Optimizations

Similar to the well-documented space optimization for the dynamic programming solution to the Longest Common Subsequence problem, both count_common_subsequences and find_common_subsequences only maintains the “current” and “previous” rows of the table that Hui Wang’s algorithm requires. As proven below, this reduces the space complexity to the following:

count_common_subsequences: 2 * min(len(seq_1), len(seq_2)) or O(min(|A|, |B|)) find_common_subsequences: 2 * min(len(seq_1), len(seq_2))^2 or O(min(|A|, |B|))^2

Additionally, unlike Professor Wang’s original paper, find_common_subsequences modifies the algorithm’s table to contain the set of subsequences achieved at the point of the algorithm’s execution as opposed to the cardinality of that set.

## Project details

Uploaded source`


text:
## On the Properties of Kullback-Leibler Divergence Between Gaussians

Feb 10, 2021

Kullback-Leibler (KL) divergence is one of the most important divergence measures between probability distributions. In this paper, we investigate the properties of KL divergence between Gaussians. Firstly, for any two $n$-dimensional Gaussians $\mathcal{N}_1$ and $\mathcal{N}_2$, we find the supremum of $KL(\mathcal{N}_1||\mathcal{N}_2)$ when $KL(\mathcal{N}_2||\mathcal{N}_1)\leq \epsilon$ for $\epsilon>0$. This reveals the approximate symmetry of small KL divergence between Gaussians. We also find the infimum of $KL(\mathcal{N}_1||\mathcal{N}_2)$ when $KL(\mathcal{N}_2||\mathcal{N}_1)\geq M$ for $M>0$. Secondly, for any three $n$-dimensional Gaussians $\mathcal{N}_1, \mathcal{N}_2$ and $\mathcal{N}_3$, we find a tight bound of $KL(\mathcal{N}_1||\mathcal{N}_3)$ if $KL(\mathcal{N}_1||\mathcal{N}_2)$ and $KL(\mathcal{N}_2||\mathcal{N}_3)$ are bounded. This reveals that the KL divergence between Gaussians follows a relaxed triangle inequality. Importantly, all the bounds in the theorems presented in this paper are independent of the dimension $n$.

* arXiv admin note: text overlap with arXiv:2002.03328


text:
On the Regularity of the Conditional Distribution of the Sample Mean

#### V. Chulaevsky

2015, v.21, Issue 3, 415-431

ABSTRACT

We show that the hypothesis of regularity of the conditional distribution
of the empiric average of a finite sample of IID random variables,
given all the sample fluctuations'', which appeared in our earlier
manuscript \cite{C10} in the context of the eigenvalue concentration analysis for multi-particle
random operators, is satisfied for a class of probability distributions
with sufficiently smooth probability density.
It generalizes a well-known property of Gaussian IID samples.

Keywords: sample mean, conditional distribution, regularity


text:
# Parallel Task Queue that runs in sequence

I'm in need of a solution that runs constantly incoming requests in a per-resource sequence, but parallel in general.

The use-case:

Many clients connect to a server and start issuing work. The work of a single client needs to run in sequential order, so the downward code doesn't need to cope with concurrency, but in general all work should be run on multiple threads. I'm trusting the .NET framework a lot here, which I hope is a good thing.

I've also read into DataFlow and parallel Rx but could not find a general solution there. But hints into that direction are welcome!

class TaskGroup
{
public int CurrentlyQueuedTasks { get { return _currentlyQueued; } }

private int _currentlyQueued;

{
}

public void Append(Action action)
{
{
Interlocked.Increment(ref _currentlyQueued);
{
try
{
action();
}catch(Exception)
{
//TODO
}
finally
{
Interlocked.Decrement(ref _currentlyQueued);
}
});
}
}
}

• It's not clear what you're asking here. Does your code work as intended? – RubberDuck Feb 6 '16 at 16:57
• Yes, it seems to work, but i haven't tested it heavily against concurrency issues. I'm also asking for improvements or maybe parts of the library that i missed. – Vengarioth Feb 6 '16 at 18:36

This is an interesting approach. I would have used a queue by default since it seems to express the semantics a bit clearer (the queuing is slightly more obvious). Also ContinueWith creates a Task wrapping the original task which I'm not sure if that has any form of performance downsides (it probably shouldn't). I hacked a quick benchmark together with the alternative being implemented using the BlockingCollection:

using System;
using System.Diagnostics;
using System.Collections.Concurrent;

public interface IAppendable
{
void Append(Action action);
}

{
public int CurrentlyQueuedTasks { get { return _currentlyQueued; } }

private int _currentlyQueued;

{
}

public void Append(Action action)
{
{
Interlocked.Increment(ref _currentlyQueued);
{
try
{
action();
}catch(Exception)
{
//TODO
}
finally
{
Interlocked.Decrement(ref _currentlyQueued);
}
});
}
}
}

public class QueueAppendable : IAppendable, IDisposable
{
public int CurrentlyQueuedTasks { get { return _Queue.Count; } }

BlockingCollection<Action> _Queue = new BlockingCollection<Action>();

public QueueAppendable()
{
{
while (true)
{
try
{
var action = _Queue.Take();
action();
}
catch (InvalidOperationException)
{
break;
}
catch
{
// TODO log me
}
}
});
}

public void Append(Action action)
{
}

public void Dispose()
{
}
}

public class Test
{
public static void TimeIt(string name, IAppendable appendable)
{
var finishEvent = new ManualResetEvent(false);
var sw = new Stopwatch();
sw.Start();
for (int i = 0; i < 2000; ++i)
{
}
appendable.Append(() => { finishEvent.Set(); });
finishEvent.WaitOne();
sw.Stop();
Console.WriteLine("{0} elapsed time: {1}ms", name, sw.ElapsedMilliseconds);
(appendable as IDisposable)?.Dispose();
}

public static void Main()
{
TimeIt("Queue", new QueueAppendable());
}
}

Output:

TaskGroup elapsed time: 2135ms
Queue elapsed time: 2121ms

So there is pretty much no performance difference between the two however I think the BlockingCollection approach has a few advantages:

1. Easier to debug. You can simply set a break point and peek the queue. This is quite difficult to do with the wrapped task approach.
2. No use use of lower level synchronization primitives. The first time I read your code I instinctively thought "Hang he's got a lock why the Interlocked calls" until I realized that the decrement happen in the async task outside of the lock. With the BlockingQueue you program against a slightly higher level of abstraction which is often a good thing.
3. Fewer class members which reduce the state complexity of the object (the queue is the only member).

Apart from that I think your approach should be fine. You may want to consider adding support for cancellation via CancellationToken

• Wait, what prevents the Queue implementation's tasks from running parallel instead of sequential? – Vengarioth Feb 13 '16 at 18:25
• @Vengarioth: The queue only has one task - the one which is pulling items of the queue and executing them. – ChrisWue Feb 14 '16 at 0:02
• Is it blocking the thread when there are no tasks in the Queue? – Vengarioth Feb 14 '16 at 20:35
• @Vengarioth: Yes, see BlockingCollection.Take – ChrisWue Feb 14 '16 at 20:36
• In my case, that is not an option unfortunately, i expanded my proposed solution to a linked list of tasks to perform basic list operations, but thank you a lot for your review! – Vengarioth Feb 17 '16 at 0:08

All you need to do is create a custom synchronization context (.NET Core no longer uses these) or custom task scheduler that schedules tasks to a single thread. Perhaps your TaskGroup could be used internally in such scheduler.


text:
QUESTION

# BSHS 385 Week 2 Individual Paper Characteristics of Nonverbal Communication

This file of BSHS 385 Week 2 Individual Paper Characteristics of Nonverbal Communication encompasses:

BSHS/385 Week 2 Individual Paper Characteristics of Nonverbal Communication

ReadChapter 6: Nonverbal communication in Floyd, K. (2011). Interpersonal Communication. (2nd ed.) New York, New York: McGraw Hill. This is found in the materials tab.

Writeat least 150 words (not including the cover page or reference page) in APA style. There is no maximum word count. Discuss the characteristics of nonverbal communication.

Tutor has posted answer for $15.99. See answer's preview$15.99


text:
source

# Least-Squares Density Difference¶

## Overview¶

The least-squares density difference detector is a method for multivariate 2 sample testing. The LSDD between two distributions $$p$$ and $$q$$ on $$\mathcal{X}$$ is defined as

$LSDD(p,q) = \int_{\mathcal{X}} (p(x)-q(x))^2 \,dx.$

Given two samples we can compute an estimate of the $$LSDD$$ between the two underlying distributions and use it as a test statistic. We then obtain a $$p$$-value via a permutation test on the values of the $$LSDD$$ estimates. In practice we actually estimate the LSDD scaled by a factor that maintains numerical stability when dimensionality is high.

For high-dimensional data, we typically want to reduce the dimensionality before computing the permutation test. Following suggestions in Failing Loudly: An Empirical Study of Methods for Detecting Dataset Shift, we incorporate Untrained AutoEncoders (UAE) and black-box shift detection using the classifier’s softmax outputs (BBSDs) as out-of-the box preprocessing methods and note that PCA can also be easily implemented using scikit-learn. Preprocessing methods which do not rely on the classifier will usually pick up drift in the input data, while BBSDs focuses on label shift.

Detecting input data drift (covariate shift) $$\Delta p(x)$$ for text data requires a custom preprocessing step. We can pick up changes in the semantics of the input by extracting (contextual) embeddings and detect drift on those. Strictly speaking we are not detecting $$\Delta p(x)$$ anymore since the whole training procedure (objective function, training data etc) for the (pre)trained embeddings has an impact on the embeddings we extract. The library contains functionality to leverage pre-trained embeddings from HuggingFace’s transformer package but also allows you to easily use your own embeddings of choice. Both options are illustrated with examples in the Text drift detection on IMDB movie reviews notebook.

## Usage¶

### Initialize¶

Arguments:

• x_ref: Data used as reference distribution.

Keyword arguments:

• backend: Both TensorFlow and PyTorch implementations of the LSD detector as well as various preprocessing steps are available. Specify the backend (tensorflow or pytorch). Defaults to tensorflow.

• p_val: p-value used for significance of the permutation test.

• preprocess_x_ref: Whether to already apply the (optional) preprocessing step to the reference data at initialization and store the preprocessed data. Dependent on the preprocessing step, this can reduce the computation time for the predict step significantly, especially when the reference dataset is large. Defaults to True. It is possible that it needs to be set to False if the preprocessing step requires statistics from both the reference and test data, such as the mean or standard deviation.

• update_x_ref: Reference data can optionally be updated to the last N instances seen by the detector or via reservoir sampling with size N. For the former, the parameter equals {‘last’: N} while for reservoir sampling {‘reservoir_sampling’: N} is passed.

• preprocess_fn: Function to preprocess the data before computing the data drift metrics. Typically a dimensionality reduction technique.

• sigma: Optionally set the bandwidth of the Gaussian kernel used in estimating the LSDD. Can also pass multiple bandwidth values as an array. The kernel evaluation is then averaged over those bandwidths. If sigma is not specified, the ‘median heuristic’ is adopted whereby sigma is set as the median pairwise distance between reference samples.

• n_permutations: Number of permutations used in the permutation test.

• n_kernel_centers: The number of reference samples to use as centers in the Gaussian kernel model used to estimate LSDD. Defaults to 1/20th of the reference data.

• lambda_rd_max: The maximum relative difference between two estimates of LSDD that the regularization parameter lambda is allowed to cause. Defaults to 0.2 as in the paper.

• input_shape: Optionally pass the shape of the input data.

• data_type: can specify data type added to the metadata. E.g. ‘tabular’ or ‘image’.

• device: cuda or gpu to use the GPU and cpu for the CPU. If the device is not specified, the detector will try to leverage the GPU if possible and otherwise fall back on CPU.

Initialized drift detector example:

from alibi_detect.cd import LSDDDrift

cd = LSDDDrift(x_ref, backend='tensorflow', p_val=.05)

The same detector in PyTorch:

cd = LSDDDrift(x_ref, backend='pytorch', p_val=.05)

We can also easily add preprocessing functions for both frameworks. The following example uses a randomly initialized image encoder in PyTorch:

from functools import partial
import torch
import torch.nn as nn
from alibi_detect.cd.pytorch import preprocess_drift

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

# define encoder
encoder_net = nn.Sequential(
nn.ReLU(),
nn.ReLU(),
nn.ReLU(),
nn.Flatten(),
nn.Linear(2048, 32)
).to(device).eval()

# define preprocessing function
preprocess_fn = partial(preprocess_drift, model=encoder_net, device=device, batch_size=512)

cd = LSDDDrift(x_ref, backend='pytorch', p_val=.05, preprocess_fn=preprocess_fn)

The same functionality is supported in TensorFlow and the main difference is that you would import from alibi_detect.cd.tensorflow import preprocess_drift. Other preprocessing steps such as the output of hidden layers of a model or extracted text embeddings using transformer models can be used in a similar way in both frameworks. TensorFlow example for the hidden layer output:

from alibi_detect.cd.tensorflow import HiddenOutput, preprocess_drift

model = # TensorFlow model; tf.keras.Model or tf.keras.Sequential
preprocess_fn = partial(preprocess_drift, model=HiddenOutput(model, layer=-1), batch_size=128)

cd = LSDDDrift(x_ref, backend='tensorflow', p_val=.05, preprocess_fn=preprocess_fn)

The LSDDDrift detector can be used in exactly the same way as the MMDDrift detector which is further demonstrated in the Drift detection on CIFAR10 example.

Alibi Detect also includes custom text preprocessing steps in both TensorFlow and PyTorch based on Huggingface’s transformers package:

import torch
import torch.nn as nn
from transformers import AutoTokenizer
from alibi_detect.cd.pytorch import preprocess_drift
from alibi_detect.models.pytorch import TransformerEmbedding

device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')

model_name = 'bert-base-cased'
tokenizer = AutoTokenizer.from_pretrained(model_name)

embedding_type = 'hidden_state'
layers = [5, 6, 7]
embed = TransformerEmbedding(model_name, embedding_type, layers)
model = nn.Sequential(embed, nn.Linear(768, 256), nn.ReLU(), nn.Linear(256, enc_dim)).to(device).eval()
preprocess_fn = partial(preprocess_drift, model=model, tokenizer=tokenizer, max_len=512, batch_size=32)

# initialise drift detector
cd = LSDDDrift(x_ref, backend='pytorch', p_val=.05, preprocess_fn=preprocess_fn)

Again the same functionality is supported in TensorFlow but with from alibi_detect.cd.tensorflow import preprocess_drift and from alibi_detect.models.tensorflow import TransformerEmbedding imports. Check out the Text drift detection on IMDB movie reviews example for more information.

### Detect Drift¶

We detect data drift by simply calling predict on a batch of instances x. We can return the p-value and the threshold of the permutation test by setting return_p_val to True and the maximum mean discrepancy metric and threshold by setting return_distance to True.

The prediction takes the form of a dictionary with meta and data keys. meta contains the detector’s metadata while data is also a dictionary which contains the actual predictions stored in the following keys:

• is_drift: 1 if the sample tested has drifted from the reference data and 0 otherwise.

• p_val: contains the p-value if return_p_val equals True.

• threshold: p-value threshold if return_p_val equals True.

• distance: LSDD metric between the reference data and the new batch if return_distance equals True.

• distance_threshold: LSDD metric value from the permutation test which corresponds to the the p-value threshold.

preds = cd.predict(X, return_p_val=True, return_distance=True)

## Examples¶

For the related MMDDrift detector.

### Image¶

Drift detection on CIFAR10

### Text¶

Text drift detection on IMDB movie reviews