text:
# How can I estimate the minimum beta for this driver to work in hard saturation?

Imagine I build the below LED driver circuit where I know all the component parameters such as 2V LED forward drop and resistors and Vcc and Vbb as in the following diagram:

And if I only dont know the beta of the NPN transistor; how can we estimate the required minimum beta for hard saturation?

In hard saturation Vce will be zero? So Ic= 9mA.

Ib = 0.9mA.

Does that mean a beta of 10 suffice for hard saturation??

• – G36 Dec 1 '19 at 20:18
• You could just assume things. Or you could go look at the datasheet for the BJT. The datasheet will usually include a diagram/chart that specifies a saturated $\beta$ when attempting to show you the base-emitter voltage vs collector current curves. It will be up in a corner of the graph somewhere. That figure usually can be taken as "acceptable" for use. But for small signal BJTs, anything less than 20 pretty much guarantees deep saturation. For a 2N3055 running at high collector currents a very low value is needed. Again, look to the datasheet. They almost always provide enough clues there. – jonk Dec 1 '19 at 20:18
• But of course, the circuit itself also has to be taken into consideration, since saturation isn't only within the BJT but is also about what's surrounding it. – jonk Dec 1 '19 at 20:19
• @jonk Should I look at Figure 3? onsemi.com/pub/Collateral/2N3055-D.PDF In my case Ic= 0.9mA. At 25 centigrade it shows a beta of 90. Is that correct to estimate beta for saturation? – GNZ Dec 1 '19 at 20:27
• Oh but it says for Vce 4V. I need for saturation – GNZ Dec 1 '19 at 20:28

Let's start with your circuit and play around with it a little bit. Beforehand, let's create a "model" for the LED. Not a complex one. Just a really simple one. But one that is complicated enough to highlight a few ideas.

Suppose that the LED voltage is: $$\V_\text{LED}=1.8\:\text{V}+I_\text{LED}\cdot 20\:\Omega\$$. The idea here is that $$\I_\text{LED}=0\:\text{mA}\$$ when $$\V_\text{LED}\le 1.8\:\text{V}\$$ and that $$\V_\text{LED}=2.0\:\text{V}\$$ when $$\I_\text{LED}=10\:\text{mA}\$$, etc. This is a simple, but not overly-simplistic model for an LED operating near its designated operating current. I'm creating this model for you because of what's coming ahead. So bear with me.

Now, let's take your circuit with two resistors and discuss it in several circumstances:

simulate this circuit – Schematic created using CircuitLab

The first two on the left are saturated. The reason is that the collector resistor is large enough to cause a sufficient voltage drop, together with the LED drop, to force the collector voltage to its VCE(sat) value. When that happens, the collector resistor determines the LED current.

I wanted to create a slightly more complicated LED model above, because I didn't want to make this too easy for you. Let's take the left-most case. An overly simple calculation using $$\V_\text{LED}=2.0\:\text{V}\$$ would suggest that $$\I_\text{LED}=\frac{15\:\text{V}-2\:\text{V}-200\:\text{mV}}{1.5\:\text{k}\Omega}\approx 8.53\:\text{mA}\$$. But the fact is, the LED voltage will be a little less than expected because of its model. And because $$\V_\text{LED}\lt 2.0\:\text{V}\$$, we can expect slightly more current. But still, $$\R_2\$$ does limit the current in the LED in the left-most example.

How do we know that the left-most circuit is saturated? We know because $$\\beta=100\$$ in active mode. But this would suggest a collector current of $$\95\:\text{mA}\$$ and that would cause $$\R_2\$$ to drop $$\142.5\:\text{V}\$$. We know this is impossible! So the BJT must be saturated.

Next towards the right is still a circuit that is saturated. Again, a simple calculation would suggest (if it weren't saturated) that the voltage drop across $$\R_2\$$ would be $$\20.9\:\text{V}\$$. And again, we know that's impossible. So the circuit must be saturated. A simplistic estimate of the current (without the fancy LED model mentioned above) would be $$\I_\text{LED}=\frac{15\:\text{V}-2\:\text{V}-200\:\text{mV}}{220\:\Omega}\approx 58.2\:\text{mA}\$$. But because the LED is dropping not quite $$\3\:\text{V}\$$ (using our fancier model), we find that the actual current is slightly less (as shown in the schematic.) Still, $$\R_2\$$ does closely limit the current in the LED.

In the 3rd case from the left (2nd from the right), we are no longer saturated. Now, we are limited by $$\\beta=100\$$ for the BJT's active mode. We can easily tell by noting that the voltage drop across $$\R_2\$$ using the maximum $$\\beta=100\$$ provides a voltage drop of $$\9.5\:\text{V}\$$. The LED itself drops $$\3.7\:\text{V}\$$. So the collector voltage is $$\1.8\:\text{V}\$$, which is definitely not a saturated collector voltage here. This means we can use $$\\beta=100\$$ for the calculations, since that's the maximum $$\\beta\$$ for this BJT. What's limiting the current in the LED now is the BJT's $$\\beta\$$. No longer is $$\R_2\$$ playing any part in it.

The 4th case (right-most) is similar. I've just further lowered $$\R_2\$$ to make the point still more obvious. The current in the LED is still limited by the BJT's $$\\beta\$$.

Note that in the last two cases (the right-most two cases), the current in the LED depends upon the BJT's active mode $$\\beta\$$. Since this varies from BJT to BJT, these two right-most circuits are not managed well. The LED current will depend a great deal on the specific BJT, it's temperature, etc. So these are not "good" switch circuits.

Note also that the 2nd from the left schematic is pretty close to active mode. It's still saturated. But it's getting close to the maximum allowed by the active mode $$\\beta\$$ of the BJT. $$\\beta=\frac{54.2\:\text{mA}}{950\:\mu\text{A}}\approx 57\$$. The value of $$\R_2\$$ is still performing its "current limiting" function, but it's getting too close to not performing that function.

This is why the left-most circuit is considered better. Here, $$\\beta=9\$$ (go ahead and check.) And this design is very safe because it's a long ways away from entering into active mode. Note also that the simplified calculation for the LED current is closer here than it is in the circuit that is 2nd from the left, despite the fact that it is still a saturated circuit.

Pushing $$\\beta\$$ lower is usually good, when operating the BJT as a switch, because it keeps you further away from active mode. The further away you are, the better. But of course, you also have to keep in mind how much extra base current is being wasted (which adds to power, as well.) So there is always a "balancing act" here. Where exactly you decide to strike that balance is your choice.


text:
### Teaching for Learning

Almost all instructors will need to lecture some of the time. An effective lecture can stimulate and involve students. A boring lecture becomes another requirement to be suffered through. Lectures are useless as a learning tool if students are not paying attention. Lectures that are poorly organized or presented in a boring way simply do not hold student attention. Let's look at some ways to develop an interesting presentation.

format: plain


text:
Question

# A resistor of $$6 k\Omega$$ with tolerance $$10\%$$ and another of $$4k\Omega$$ with tolerance $$10\%$$ are connected in series.The tolerance of combination is about

A
5%
B
10%
C
12%
D
15%

Solution

## The correct option is B $$10\%$$In series combination,$$R=R_1+R_2=6+4=10 k\Omega$$Error in combination$$\Delta R=\Delta R_1+\Delta R_2$$$$\dfrac{10}{100}\times 6+\dfrac{10}{100}\times 4$$$$=0.6+0.4=1$$$$\therefore \dfrac{\Delta R}{R}=\dfrac{1}{10}=10\%$$Physics

Suggest Corrections

0

Similar questions
View More

People also searched for
View More


text:
Close
Enter your search into one or more of the boxes below:
You can refine your search by selecting from any of the options below:
Search
Clear
Categories
Science & MathematicsMathematicsCalculus & mathematical analysis
/science-mathematics/mathematics/calculus-mathematical-analysis
0
Clear all
Selections
Clear
Clear
Clear
Clear
Clear
Clear
Clear
Clear all
Refine by
Clear
Availability
To Order From Suppliers
Pre-Orders
1
Clear
Highlights & Offers
New Arrivals
Current Favourites
Bestsellers
Signed Copies
Promotions
Over 30% or more off
Coming Soon
Top Tens
1
Foyles Recommends
Staff Choice
Author Choice
Customer Choice
Customer Rating
1
Clear
Formats
Books
eBooks
Audiobooks
Digital or Media
Sheet Music
Maps
1
Clear
In Language
Afrikaans
Albanian
Amharic
Arabic
Armenian
Assamese
Assyrian
Awa
Azerbaijani
Balinese
Balti
Basque
Belarusian
Bemba
Bengali
Bislama
Bosnian
Breton
Bulgarian
Burmese (Myanmar)
C. African General
C. Asian General
Cambodian/Khmer
Caribbean Creole
Catalan
Caucasus General
Chechen
Chichewa
Chinese: Cantonese
Chinese: Mandarin
Cornish
Croatian
Czech
Danish
Dari
Dholuo
Dutch
E. African General
E. European General
English
Esperanto
Estonian
Faroese
Fijian
Finnish
French
General L&L
Georgian
German
Greek
Greenlandic
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hindustani
Hungarian
Ibo/Igbo
Icelandic
Ilokano
Indian General
Indonesian
Ingush
Inuktitut
Irish
Italian
Jamaican English
Japanese
Javanese
Jèrriais
Karao
Kashmiri
Kazakh
Khasi
Kirghiz
Kisi
Konkani
Korean
Kurdish
Kwamera
Lakota
Lao
Latin
Latvian
Lingala
Lithuanian
Luganda
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maldivian
Maltese
Mambwe
Mandinka
Manipuri
Manx
Maori
Marathi
Mauritian
Mongolian
Multilingual
Navajo
Nepali
Nordic General
Northern Sotho
Norwegian
Old English
Oriya
Oshindonga
Other Euro General
Pacific General
Pali
Papiamento
Pashto/Pushto
Persian/Farsi
Pidgin
Polish
Portuguese
Punjabi
Quechua
Romanian
Rotuman
Russian
S. African General
S. American General
Samoan
Sanskrit
Scottish Gaelic
Senoi
Serbian
Serbo-Croat
Sesotho
Setswana
Shona
Sign Language
Sindhi
Sinhalese
Slovak
Slovene
Somali
Spanish
Swahili
Swedish
Syriac
Tagalog (Filipino)
Tahitian
Taiwanese: Hokkien
Tajik
Tamazight
Tamil
Tatar
Telugu
Thai
Tibetan
Tigrinya
Tokelau
Tolo
Tongan
Tsonga
Tswana
Turkish
Turkmen
Tuvaluan
Twi
Ukrainian
Urdu
Uzbek
Vietnamese
W. African General
Wankumara
Warndarang
Welsh
White Hmong
Wolof
Xhosa
Yiddish
Yoruba
Zulu
1
Clear
Price
£to £

 SSL Certificates

## Showing 1-16 of top 150 Results. 12345 Next »

This book-an outgrowth of an international conference held in honor of Jacques PeyriÃ¨re-provides readers with an overview of recent developments in the mathematical...

This unique blend of excellent writting and innovation will appeal to students of all abilities. Whilst still challenging more competant students and giving them a deeper understanding of calculus...
Applied Calculus (Paperback)

The 5th Edition of "Applied Calculus" continues to exhibit the same strengths from earlier editions including a focus on creative conceptual and modeling problems and...

This book contains a collection of recent research papers originating from the 6th Workshop on Operator Theory in Krein Spaces and Operator Polynomials, which was held...

These authors understand what it takes to be successful in mathematics, the skills that students bring to this course, and the way that technology can be used to...

These papers are taken from the fourth conference on "Symmetry and Perturbation Theory" (SPT 2002). The proceedings present original results and state-of-the-art reviews on topics related to symmetry, integrability and...

System Modelling and Optimization covers research issues within systems theory, optimization, modelling, and computing. It includes contributions to...

Analysis, Control and Optimization of Complex Dynamic Systems gathers in a single volume a spectrum of complex dynamic systems related papers written by experts in...

Based on the International Federation for Information Processing WG 7.2 Conference, held in Pisa, Italy, this title provides results as well as fresh material on control theory and shape analysis.

Multivariate polysplines are a new mathematical technique that has arisen from a synthesis of approximation theory and the theory of partial differential equations. This book develops the theory of cardinal...

Develops the application of experimental statistical designs and analysis to discrete-event simulation modelling. The stages and steps for applying simulation are discussed by focusing on the role of statistics. Using...

This volume contains a multiplicity of approaches brought to bear on problems varying from the formation of caustics and the propagation of waves at a boundary, to the...

This textbook presents a unified approach to compact and noncompact Riemann surfaces from the point of view of the so-called L2 $\bar{\delta}$-method. This method ...

Linear Chaos (Paperback)

It is commonly believed that chaos is linked to non-linearity, however many (even quite natural) linear dynamical systems exhibit chaotic behavior. The study of these...

## 12345 Next »

Total number of items: 0
Sub total: £0.00
Select Currency: \$ £
Latest Blog
GUEST BLOG: That Bergerac moment
21/04/2014

David Mark, author of the DS Aector McAvoy series of crime novels, reveals what watching Bergerac and He-Man as a child taught him about character development.

GUEST BLOG: Tackling taboos the Mirabelle Bevan Way
18/04/2014

Sara Sheridan, author of the 1950s-set Mirabelle Bevan Mysteries, explains how she tackles subjects that were taboo at the time, like sex and violence.

Once upon a time in the west
15/04/2014

While Westerns remain popular in America, they have largely fallen out of favour with British readers. This is a great pity, suggests Joshua from our Waterloo branch, as they are missing out on some wonderful fiction, both classic and contemporary.

View all Blog Entries
News


text: Exercise & Fitness Or you get a headache and an energy crash when you “come down.” Your CA Privacy RightsYour CA Privacy Rights 31: 1 (35%) Ultra Omega-3 Softgels Ginkgo Biloba Leaf(23% extract), Phosphatidylserine 4% Complex(consisting of Lecithin and Phosphatidylserine),N-Acetyl L-Carnitine HCI, St. John's Wort(0.3% extract)(fower heads),L-Glutamine,Dimethylaminoethanol Bitartrate, Bacopa monnieri Leaf Extract(20% bacosides), Vinpocetine(seeds), Huperzine-A(aerial Plant) ; other ingredients: Gelatin(bovine), vegetable magnesium stearate, microcrystalline cellulose and silicon dioxide Gomez-Ramirez M, et al.The deployment of intersensory selective attention: a high-density electrical mapping study of the effects of theanine. Clin Neuropharmacol. 2007 Jan-Feb;30(1):25-38 70 pairs is 140 blocks; we can drop to 36 pairs or 72 blocks if we accept a power of 0.5/50% chance of reaching significance. (Or we could economize by hoping that the effect size is not 3.5 but maybe twice the pessimistic guess; a d=0.5 at 50% power requires only 12 pairs of 24 blocks.) 70 pairs of blocks of 2 weeks, with 2 pills a day requires (70×2)×(2×7)×2=3920(70 \times 2) \times (2 \times 7) \times 2 = 3920 pills. I don’t even have that many empty pills! I have <500; 500 would supply 250 days, which would yield 18 2-week blocks which could give 9 pairs. 9 pairs would give me a power of: Current ye@r * Because of this relatively stringent requirements, when most people use the word ‘nootropic drug’ they simply mean a chemical that is supposed to enhance cognitive functioning – side effects or not. off2 Try your luck OptiMind Acetyl-L-Carnitine Powder Voucher Codes Includes Lion’s Mane nootropic actives: hericenones and erinacines. Here’s yet another brain boosting supplement that you should consider; Max Synapse works to restore neurons in the brain by providing necessary nutrients required by brain cells. According to its manufacturer, UltraMax Health, Max Synapse is perfectly safe for all users. In fact, a team of scientists tested the efficacy of all components to ensure effectiveness and safety. In mice with reduced blood flow to the brain (chronic cerebral hypoperfusion), Huperzine A treatment reduced cognitive impairment by [R]: Bars, Drinks & Foods 50. Schneider, Z., & Stroinski, A. (1987). Comprehensive B12: chemistry, biochemistry, nutrition, ecology, medicine: Walter de Gruyter. 14 hours ago NCBI: Nutrition Concerns for Aging Populations NGF (Nerve Growth Factor) Stack November 29, 2017 • 6 min read 3 Key Health Benefits of Vitamin B6 as Pyridoxal-5-Phosphate (P5P) By: DAVE ASPREY Organic Hot Cream Reprinting this article: 50 - Probiotic and Gut Health Product Finder - Question 2 - GI Regularity Fun, quick Brain Teasers # NOTE: n is number of *pairs*, sd is std.dev. of *differences* within pairs qplot(Date, MP, color=as.factor(Magnesium.citrate), legend="Magnesium citrate", size=I(7)) + Lengthens attention span Flours, Powders & Baking Mixes Chronic Fatigue Syndrome MCT Oil Interest-Based AdsInterest-Based Ads Profiderall How To Spot A Genuinely Top Nootropic Elevates Acetylcholine levels Safety issues Get the latest news on health and wellness delivered to your inbox! Grocery Store Permalink to this article: # sig.level = 011.05 CoQ10 enhances cellular energy production in your mitochondria, giving you both a mental and physical boost. [14] (The dose of CoQ10 is low, but it’s in a colloidal form which potentiates delivery of the PQQ) $149.95 As low as:$127.46 Abstract See footnote for R code Books & Media NewsPulse Supplies dozens of brain-protective flavonoid antioxidants in one complex In each pair, try to pick the photo with a lightened iris eye color if any. (Do not judge simply on overall lighting.) More Diseases & Conditions # 16 0.53 0.62 0.465 -13 8.7e-07 NA 5.5 0.77 NA NA NA 2.1 8.6e-07 2.2e-06 10: 0 (30%) (Refer to this chart for Cognitex® with Pregnenolone & Brain Shield® nutritional facts). As I am not any of the latter, I didn’t really expect a mental benefit. As it happens, I observed nothing. What surprised me was something I had forgotten about: its physical benefits. My performance in Taekwondo classes suddenly improved - specifically, my endurance increased substantially. Before, classes had left me nearly prostrate at the end, but after, I was weary yet fairly alert and happy. (I have done Taekwondo since I was 7, and I have a pretty good sense of what is and is not normal performance for my body. This was not anything as simple as failing to notice increasing fitness or something.) This was driven home to me one day when in a flurry before class, I prepared my customary tea with piracetam, choline & creatine; by the middle of the class, I was feeling faint & tired, had to take a break, and suddenly, thunderstruck, realized that I had absentmindedly forgot to actually drink it! This made me a believer. Grocery Store Founded in 2005 by Dr. Shaheen Lakhan, Brain Blogger is an official undertaking of the Global Neuroscience Initiative Foundation (GNIF) — an international charity for the advancement of neurological and mental health patient welfare, education, and research. It is one of the most effective mediums for the GNIF to raise awareness of neuro-related topics. Corporate More Info off <- c(25,34,30,40,57,34,41,51,36,26,37,42,40,45,31,24,38,40,47,35,31,27,66,25,17,43,46,50,36, It's, ahem, an illuminating story. Only available at the official website – www.NooCube.com Nootropics – sometimes called smart drugs – are compounds that enhance brain function. They’re becoming a popular way to give your mind an extra boost. According to one Telegraph report, up to 25% of students at leading UK universities have taken the prescription smart drug modafinil [1], and California tech startup employees are trying everything from Adderall to LSD to push their brains into a higher gear [2]. ~ A Beginner’s Guide to Nootropics, on the nootropics Reddit page 3. Ginkgo Biloba Together in Mind Lab Pro®, these two nootropics help to support mood via separate complementary brain pathways. 80 NATURE INGREDIENTS Smart Pill Face-off: Lumonol vs. Evo Why Brain Smart? Hundreds of these items can be found on the market, and it’s difficult for most people to choose the right one which can be stressful. Now, you can be completely stress-free as this article brings you useful info about the best Cognitive Enhancing* Supplements in 2018. The best nootropic supplements may include Vitamins B6, B9 and B12 to help regulate homocysteine, thereby supporting brain chemical conversion and healthy blood flow to the brain. Loading... Multi-pathway nootropics – using several nootropics to address one aspect of cognition; or using one nootropic with several brain benefits For example, Provasil memory supplement doesn’t only have a list of ingredients on the official website, but their amounts as well which proves the reliability of the product. Just by browsing through the official website you can find out the product contains resveratrol, ginseng, ginkgo, bacopa, acetyl-l-carnitine, choline, vitamin B12, Vitamin C etc. Top Nootropics for Mental Performance & Brain Support Bacopa monnieri dose: At least 750 mg daily, taken with a source of fat All Car Buying & Pricing Advice 1 PM; overall this was a pretty productive day, but I can’t say it was very productive. I would almost say even odds, but for some reason I feel a little more inclined towards modafinil. Say 55%. That night’s sleep was vile: the Zeo says it took me 40 minutes to fall asleep, I only slept 7:37 total, and I woke up 7 times. I’m comfortable taking this as evidence of modafinil (half-life 10 hours, 1 PM to midnight is only 1 full halving), bumping my prediction to 75%. I check, and sure enough - modafinil. Probiotic and Gut Health Product Finder - Question 2 - Overall Immune Health Heart Failure Free memory recall [R]. Your CA Privacy Rights The ketogenic diet is a game changer when it comes to boosting overall brain power and productivity. One of the most popular legal stimulants in the world, nicotine is often conflated with the harmful effects of tobacco; considered on its own, it has performance & possibly health benefits. Nicotine is widely available at moderate prices as long-acting nicotine patches, gums, lozenges, and suspended in water for vaping. While intended for smoking cessation, there is no reason one cannot use a nicotine patch or nicotine gum for its stimulant effects. active mind supplement|best brain performance supplements active mind supplement|best brain supplements 2012 active mind supplement|best brain supplements 2013


text:
Prove the following trigonometric identities.
Question:

Prove the following trigonometric identities.

If $3 \sin \theta+5 \cos \theta=5$, prove that $5 \sin \theta-3 \cos \theta=\pm 3$.

Solution:

Given: $3 \sin \theta+5 \cos \theta=5$

We have to prove that $5 \sin \theta-3 \cos \theta=\pm 3$.

We know that, $\sin ^{2} \theta+\cos ^{2} \theta=1$

Squaring the given equation, we have

$(3 \sin \theta+5 \cos \theta)^{2}=(5)^{2}$

$\Rightarrow \quad 9 \sin ^{2} \theta+2 \times 3 \sin \theta \times 5 \cos \theta+25 \cos ^{2} \theta=25$

$\Rightarrow 9\left(1-\cos ^{2} \theta\right)+2 \times 3 \sin \theta \times 5 \cos \theta+25\left(1-\sin ^{2} \theta\right)=25$

$\Rightarrow 9-9 \cos ^{2} \theta+2 \times 3 \sin \theta \times 5 \cos \theta+25-25 \sin ^{2} \theta=25$

$\Rightarrow \quad 34-\left(9 \cos ^{2} \theta-2 \times 3 \sin \theta \times 5 \cos \theta+25 \sin ^{2} \theta\right)=25$

$\Rightarrow \quad-\left(25 \sin ^{2} \theta-2 \times 5 \sin \theta \times 3 \cos \theta+9 \cos ^{2} \theta\right)=-9$

$\Rightarrow \quad\left(25 \sin ^{2} \theta-2 \times 5 \sin \theta \times 3 \cos \theta+9 \cos ^{2} \theta\right)=9$

$\Rightarrow \quad(5 \sin \theta-3 \cos \theta)^{2}=9$

$\Rightarrow \quad 5 \sin \theta-3 \cos \theta=\pm 3$

Hence proved.


text:
# How to make a Flash movie with a transparent background

This works flawlessly in IE. The background renders correctly in Firefox and Safari, however as soon as you use the browser's scroll bar then mouse over the Flash control you must click once to activate the control. You can see this behavior if you try to hit the play button in Adobe's example.

Anyone know a way around this?

You know you can set the background color when you're embedding?

The following attributes are optional when defining the object and/or embed tags. For object , all attributes are defined in param tags unless otherwise specified:

bgcolor - [ hexadecimal RGB value] in the format #RRGGBB . Specifies the background color of the movie. Use this attribute to override the background color setting specified in the Flash file. This attribute does not affect the background color of the HTML page.

On another note; setting the wmode to transparent has a few kinks. For instance it can break the scrolling (the flash stays in the same place disregarding the scroll) in some older versions of Firefox (pre 2.0). I've also had issues with ALT-key combinations in textfields not working when wmode is transparent.

Also, if you need to place html-content above flash-content (not a good idea generally, but there are cases when it's useful) wmode=transparent is the way to go.

Enabling windowless mode (wmode=) makes embedded flash act and render just like other elements. Without that, it's rendered in a seperate step and just overlaid on the browser's window.

Could the flash element be losing focus? Sounds like input focus is moved to the scollbar, then you have to move it back.

Also you weren't clear whether the focus issue was only in FF or also in IE.

The Adobe example "works" in Firefox 3.0.1 in the sense that the background is transparent. However, in Firefox 3.0.1 and Safari 3.1.2 you must click the play button twice to see the animation.

After spending some more time on this I agree with @grapefrukt. Setting wmode to transparent leads to all sorts of strange issues and in my opinion it should be avoided.

Instead I've resorted to passing the background color as a parameter. I use the following ActionScript to draw the background.

var parameters:Object = LoaderInfo(this.root.loaderInfo).parameters;
opaqueBackground = parameters["background-color"];

EDIT: Thanks to @grapefrukt for reminding me of the bgcolor param (which makes the ActionScript above totally unnecessary)


text:
variance of cauchy distribution
16273
Where should small utility programs store their preferences? To use the Cauchy aka Lorenzian distribution in Analytica, add the Distribution Variations library to your model, and then use the function Lorenzian(m,s). Doesn't that discrete distribution have the same weirdness of no mean and no variance? We consider two methods to generate Cauchy variate samples here. How to limit population growth in a utopia? To learn more, see our tips on writing great answers. Why is the sample distribution the Exponential distribution Gamma distributed? Distribution of sample variance of Bernoulli variables. Cauchy Distribution The Cauchy distribution, or the Lorentzian distribution, is a continuous probability distribution that is the ratio of two independent normally distributed random variables if the denominator distribution has mean zero. Cauchy convolution with other distribution, Mean/Variance of Uniform Probability Distribution. If nobody knows the exact distribution of the sample variance, it would be interesting if the distribution is independent of number of samples $n$? New comments cannot be posted and votes cannot be cast, Press J to jump to the feed. I would like to know the distribution of the sample variance $$\frac{1}{n}\sum_{i=1}^n \left(X_i-\bar{X}_n\right)^2 .$$. For a better experience, please enable JavaScript in your browser before proceeding. After reading the whole (in my opinion very badly written) paragraph. The Cauchy distribution (which is a special case of a t-distribution, which you will encounter in Chapter 23) is an example of a distribution that does not have a finite variance – in fact, the Cauchy distribution does not even have a finite mean. I know that linear combinations of independent cauchy random variables is chauchy distributed as well. Cookies help us deliver our Services. 1 3099067, This website uses cookies to ensure you get the best experience on our website, Journal of the American Statistical Association, Journal of Statistical Computation and Simulation, The online home for the publications of the American Statistical Association, Variance of the Median of Samples from a Cauchy Distribution, Aeronautical Research Laboratories, Wright-Patterson Air Force Base , USA, /doi/pdf/10.1080/01621459.1960.10482066?needAccess=true, A Note on Estimation from a Cauchy Sample, Tests of the Hypothesis That a Linear Regression System Obeys Two Separate Regimes, A Note on the Estimation of the Location Parameter of the Cauchy Distribution, Order Statistics Estimators of the Location of the Cauchy Distribution, Estimating the variance of the sample median. For larger $n$ we need to do more work to show that the distributions change, one way is to compute sufficiently detailed asymptotics for the characteristic functions. For random variables with finite first moment, the mean comes out in a very natural way as the 'average' of repeated samples of the distribution. It only takes a minute to sign up. I would like to know the distribution of the sample variance $$\frac{1}{n}\sum_{i=1}^n \left(X_i-\bar{X}_n\right)^2 .$$ My foreknowledge: Shouldn't some stars behave as black hole? Basically: the area under the curve is infinite, so the integral is infinite. For example, when $n=1$ it is zero and for $n=2$ we have a quantity related to the difference of two iid Cauchy random variables. The point of calculating moments of random variables in the first place (c.f. Where is the mistake I'm making in considering a continuous distribution the same way as a discrete one? They are compared with the values obtained by using the formula for asymptotic variance. Cauchy Distribution The Cauchy distribution, or the Lorentzian distribution, is a continuous probability distribution that is the ratio of two independent normally distributed random variables if the denominator distribution has mean zero. APPL veriﬁcation: The APPL statements If you're just looking for quantities of spread, then perhaps you could check the "interquartile range". I know that $\bar{X}_n:=\frac{1}{n}\sum_{i=1}^n X_i$ is standard Cauchy distributed. the interquartile range seems to be an interesting indicator. Active 1 year, 4 months ago. Say $N$ is a million for the sake of illustration. It is a “pathological” distribution, i.e. It is a “pathological” distribution, i.e. What's the implying meaning of "sentence" in "Home is the first sentence"? Using of the rocket propellant for engine cooling. Well, the weak law of large numbers fails for (iid copies of) the Cauchy distribution. Cauchy Distribution The Cauchy distribution has PDF given by: f(x) = 1 ˇ 1 1 + x2 for x2(1 ;1). Assume $X_i,i\in\left\{1,...,n\right\}$ are i.i.d. 2 Generating Cauchy Variate Samples Generating Cauchy distributed RV for computer simulations is not straight-forward. What about the discrete distribution over the integers with probability 1/(1+n2 )? Then your mistake is that you interpret the integral [; \int_{-\infty}^{\infty} x f(x) dx ;]as [; \lim_{y\rightarrow\infty} \int_{-y}^{y} x f(x) dx = \lim_{y\rightarrow\infty} 0 = 0 ;]. Were any IBM mainframes ever run multiuser? Wait! By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy. come from a distribution with finite variance. Use MathJax to format equations. So you certainly won't observe that the mean is 0 if you take independent samples from the Cauchy distribution (as is mentioned in the comments). Please check your Tools->Board setting. That’s a very natural transformation to consider, so clearly the distribution is interesting. Registered in England & Wales No. Note that R 1 1+x2 dx= arctan(x). Variance of the Median of Samples from a Cauchy Distribution. Looking up values in one table and outputting it into another using join/awk. If you doubt it, simply run a simulation and you will see that as your runs get higher the expectation gets higher too, instead of actually converging. How do smaller capacitors filter out higher frequencies than larger values? (1960). JavaScript is disabled. Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields.


text:
# Graphing Parabolas in the Form y = ax^2

In this video, we will look at graphing the parabola $1x^2$ and what happens when the coefficient is greater or less then one.
How do you think the parabola $y = 4x^2$ would look? Make a prediction, then watch the video below.


text:
This post is not going to be very maths-heavy but will include some concepts from the area of graph theory which we will use in an unusual setting.

Today we’re going to get into the virtual kitchen and get our virtual taste buds a-buzzing….Well, actually we’re going to get our computers to do the hard work of finding out some tasty recipes and we’re going to use a few different techniques to do this. The workhorse is going to be the Mathematica programming language, but a lot of what we will do will be doable in any programming language, though perhaps it will be slightly more cumbersome than this.

The starting point of our culinary adventure will be a piece of text, taken from a website of flavour pairings here.

We see here that we have a piece of text which we can copy and paste into our Mathematica file. The text starts:

• Allspice pairs well with: apples, beets, cabbage, caramel, cardamom, cinnamon, cloves, coriander, ginger, juniper, mace, mustard, nuts, nutmeg, onions, pears, pumpkin, root vegetables, yams
• Almond pairs well with: apple, apricot, banana, caramel, cherry, coffee, fig, honey, orange, peach, pear, plum
• Anice pairs well with: apples, beets, caramel, carrots, chocolate, citrus, cinnamon, coconut, coriander, cranberry, fennel, figs, fish, garlic, peaches, pomegranates, pumpkin
• Apple pairs well with: caramel, cardamom, chestnut, cinnamon, cranberry, currant, ginger, hazelnut, mango, maple, rosemary, walnut
• Apricot pairs well with: almond, black pepper, caramel, cardamom, ginger, hazelnut, honey, orange, peach, vanilla, plum
• Asian Pear pairs well with: ….
• and so on…

The aim of this exercise will be to take this data and try and write some code which will automatically generate recipes for us (at least in terms of the combinations of ingredients which will go well together).

At the moment the whole thing is one very long string (data made up of symbols which don’t have a specific meaning as a command in a programming sense), and we would like to split the string up into more bite-sized (haha!) chunks which we can put into a lovely visual form and then pull out recipes from it.

I will add a second post regarding exactly how we will do this, but the topics which will be needed are:

• Text processing including regular expressions and edit distance (a concept from the world of natural language processing)
• Functional and symbolic programming
• Concepts from Graph Theory

We will show in the detailed post that we can extract from the text all the details about which food goes well with which in a simple matrix form. How can we display this graphically? Well, we can think that every ingredient is a point, and every statement “A goes well with B” is a line joining ingredients (points) A and B. Thus, the information is well represented as a graph. Not a graph in the sense of a graphical representation of a function from x to y (f:$\mathbb R\rightarrow \mathbb R$), but a graph in the sense of a series of vertices (also called nodes) and lines joining them .

Graphs are ubiquitous in the natural description of many areas of life, from computer networks to real life social networks, from evolutionary biology to, apparently, gastronomy! (Postscript: Apparently something similar has been done before – see here)

Let’s look at how all the data looks if we plot it as a single graph

well this is useful for neither chef nor beast…

In fact the total number of ingredients in the list is too large to plot the whole thing on a single page, and to be able to read the details, so let’s plot just a subset of them (also known as a subgraph). Here are a few ingredients (randomly chosen) displayed in a graph:

Remember, each line (also called an edge in graph theory) joining two ingredients (vertices) means that they go well together. So caramel and pear go well together and coconut and curry leaf go well together. Remember that this is simply a small sampling of ingredients and links, and so there are links here which should be there in the full data but are not. For instance pear and vanilla go well together.

So, what is a recipe? Well, we can think (in a very simplified way) that a recipe is a set of ingredient where each one goes well with each other. See the video of Grant Achatz from Alinea here:

What does this mean in the sense of the graph? Well, it will be a set of points where each point is connected to every other in the set. This can also be described as a totally connected subgraph, also known as a clique.

Thus, if we find the cliques in the graph, we will have found recipes!

We can ask for cliques of a given size, so, for instance the following graph has a single clique with 3 vertices:

Here you can see that mandarin goes well with nutmeg, mandarin goes well with cinnamon and cinnamon goes well with nutmeg. Three ingredients which go well together and thus a recipe of three ingredients is formed…ok, so not quite a recipe, but at least a list of ingredients which can become the basis of a recipe.

However, to pull out the useful information, ie the cliques, we don’t need to be able to look at the data in graph form, we simply need to be able to ask for cliques, and luckily in Mathematica, this is pretty easy. We simply write

FindCliques[graph, {clique_size_you_want}, All]

…easy as that!

For instance, we can ask for cliques with 7 elements in, and (a subset of) the answers are:

• onion, fennel, dill, basil, thyme, oregano , parsley
• rosemary, basil, marjoram, thyme, mushrooms , oregano, parsley
• fennel, garlic, dill, basil , thyme, oregano, parsley
• caraway, paprika, garlic, dill, thyme, oregano, parsley
• allspice, apple, cardamom, cilantro, clove, coriander, ginger
• cardamom, cilantro, clove, coriander, cumin , ginger, curry
• cardamom, cilantro, clove, coriander, cumin, ginger, citrus
• allspice, cardamom, cilantro , clove, coriander, cumin, ginger
• allspice, apple, caramel, cardamom, cinnamon, ginger, pear
• cardamom , cinnamon, clove, coriander, cumin, ginger , curry
• allspice, apple, cardamom, cinnamon, clove , coriander, ginger
• chocolate, cinnamon, clove, ginger , nutmeg, orange, vanilla

Actually Mathematica only finds cliques like this which are not subgraphs of larger cliques (known as maximal cliques), so we have to work a little harder to find all 40 or so cliques of size 7.

Well, that’s kinda neat – we’ve just found sets of 7 ingredients, all of which go well with one another. For any cooks out there, these combinations won’t be particularly surprising, though the allspice, apple, cardamom, cilantro, clove, coriander, ginger combination is perhaps a little unusual and sounds quite a bit like a variation of a Vietnamese salad.

We can do better than this. We can ask for cliques which contain certain ingredients, or even combinations of ingredients. For instance we can ask for cliques with vanilla and lemongrass. Apparently there are two cliques with these ingredients, the largest of which is chocolate, coconut, ginger, vanilla, lemongrass which sounds pretty interesting!

We can also ask about ingredients which might go badly together – these may be thought of as those ingredients which have the longest path in between them. Given a graph g,  we can find these very simply with the command:

longestpath=

With[{vl=VertexList[g]},Table[FindShortestPath[g, vl[[m]], vl[[n]]]//Length, {m, Length[vl]}, {n, Length[vl]}]//Max]

With[{vl=VertexList[g]},{vl[[#[[1]]]], vl[[#[[2]]]]}&/@Position[Table[FindShortestPath[g, vl[[m]], vl[[n]]]//Length, {m, Length[vl]}, {n, Length[vl]}],longestpath]]

Don’t worry about the syntax here if you are not familiar with Mathematica – this is just asking for the maximal shortest path between ingredients.

This gives a large number of different pairs of ingredients which have 4 ingredients in between them. For instance apparently eggplant and white chocolate wouldn’t make a great pairing according to the following:

However, I’m not completely convinced about some of the supposedly bad combinations.  For instance, apparently maple and watermelon are very bad flavour pairings. This certainly doesn’t seem like a bad combination to me and so I think that we are seeing the limitation with the relatively small number of flavour pairings shown in the text. We would need a more comprehensive flavour pairing list in order to investigate this further.

There are some rather surprising combinations of flavours which go well together. For instance, caviar and white chocolate is supposed to be a good pairing due to the presence of certain amine compounds in both of them.

Ok, so these are some of the simple things we can play around with. In the next post I will show how we actually coded this in Mathematica using concepts like Editdistance and some simple graph theoretic commands.

Part 2 can be found here.

 How clear is this post?


text:
# Reduce the output from tuples by including symmetry?

I need all the possible 3x3 binary tensors, but I'd like to have this account for symmetries. I've started by using the Tuples command.

Tuples[{1, 0}, {3, 3}]

This tuples command produces 512 binary tensors. If I consider tensors that are symmetric by any permutation to be redundant, how can I remove the extraneous ones from the output? Here are a few examples of tensors that I'd like to consider as the same:

{{0, 1, 0}, {0, 1, 0}, {1, 1, 0}} // MatrixForm
{{1, 1, 0}, {0, 1, 0}, {0, 1, 0}} // MatrixForm
{{0, 1, 0}, {0, 1, 0}, {0, 1, 1}} // MatrixForm
{{0, 0, 1}, {1, 1, 1}, {0, 0, 0}} // MatrixForm

Additionally, I'd like to remove tensors that are equal if you replace the 1's with 0's, and vice versa, such that these two tensors are equivalent:

{{1, 0, 1}, {1, 0, 1}, {0, 1, 0}} // MatrixForm
{{0, 1, 0}, {0, 1, 0}, {1, 0, 1}} // MatrixForm

By my estimation, this should reduce the output from 512 to ~50 tensors.

Any help would be greatly appreciated.

Clarification of "permutations" for the original question:

I'm not sure the most accurate way to describe it. Imagine taking a 3x3 array of 1's and iteratively changing each 1 to a 0 until you have an array of 0's. I consider a duplicate being an array that is identical under any rotation or mirror around any row or diagonal.

{{1, 1, 1}, {1, 1, 1}, {1, 1, 1}}

There are only three distinct 1's that can be removed:

{{0, 1, 1}, {1, 1, 1}, {1, 1, 1}}
{{1, 0, 1}, {1, 1, 1}, {1, 1, 1}}
{{1, 1, 1}, {1, 0, 1}, {1, 1, 1}}

-
It is unclear what you mean by "permutation." Is it that (1) the permutation group $S_9$ on all nine tensor elements is acting (probably not; you would get only five equivalence classes--but your example strongly suggests this is what you mean) or (2) $S_3$ acts independently on the two indexes (a group of order $36$) or (3) $S_3$ acts simultaneously on the two indexes (a group of order $6$)? –  whuber Mar 10 '13 at 15:17
Can you clarify what you mean by permutation? What is it that you are permuting exactly? Rows? Columns? Both at the same time? Tensor indices? –  Szabolcs Mar 10 '13 at 16:53
@whuber (3) would amount to constructing all unlabelled graphs with at most 3 vertices, right? –  Szabolcs Mar 10 '13 at 17:00
@Szabolcs I believe so, upon interpreting these arrays as incidence matrices. I think you need to use graphs with exactly three vertices and to allow edges to connect vertices to themselves. Clearly such arrays do determine graphs; conversely, given such a graph, we may label its vertices in one of six unique ways (this is why three vertices are needed, not just at most three) and such a labeling determines a $3\times 3$ incidence matrix; a change of labels simultaneously permutes both the rows and columns of that matrix. –  whuber Mar 10 '13 at 17:18

First, get set t2 by removing those tensors that are permutations. Second, get set t3 by removing the tensors that are equivalent when the 0-1 substitutions are considered.

t = Tuples[{1, 0}, {3, 3}];
t2 = DeleteDuplicates[t, Sort@#1 == Sort@#2 &];
t3 = DeleteDuplicates[t2, Sort@(#1 /. {0 -> 1, 1 -> 0}) == Sort@#2 &];
Length@t3

This gives a list with 60 tensors.

Edit:

Given the enhanced explanation about the permitted transformations, I think the following approach may give some idea on how to remove the redundant tensors. Here, I consider the rules that check the mirroring. In its present form, this solution gives 212 matrices (in t2), the number of which can be further reduced by including additional conditions for equivalent tensors (like the 0-1 substitutions). If you also consider tensors being equivalent after multiple mirroring operations, etc., those have to be also implemented. Although this approach seems quite tedious, I hope it may still be satisfactory.

t = Tuples[{1, 0}, {3, 3}];
t2 = DeleteDuplicates[t,
#1 == Reverse@#2(*mirror with respect to the 2nd row*)||
#1 == Reverse[#2, 2](*mirror with respect to the 2nd column*)||
#1 == Transpose@#2(*diagonal*)||
#1 == Reverse@Transpose@Reverse@#2(*the other diagonal*)
&];

Edit 2:

Ok, so let me try to complete this answer. The solution by @dpholmes provides the answer to the first part of the question. Here, I will continue from that (list t2) and show how to take into account also the 0-1 substitutions. This results in 51 distinct arrays (t3).

t = Tuples[{1, 0}, {3, 3}];
t2 = DeleteDuplicates[t,
#1 == Reverse@#2(*mirror with respect to the 2nd row*)||
#1 == Reverse[#2, 2](*mirror with respect to the 2nd column*)||
#1 == Transpose@#2(*diagonal*)||
#1 == Reverse@Transpose@Reverse@#2(*the other diagonal*)||
#1 == Reverse@Transpose@Reverse@Reverse[#2, 1]
(*mirror with respect to the 2nd row and first diagonal*)||
#1 == Reverse@Transpose@Reverse@Reverse[#2, 2]
(*mirror with respect to the 2nd row and other diagonal*)||
#1 == Reverse[Reverse[#2], 2]
(*mirror with respect to the 2nd row and the 2nd column*)
&];
t3 = DeleteDuplicates[t2,
(#1 /. {1 -> 0, 0 -> 1}) == Reverse@#2(*mirror with respect to the 2nd row*)||
(#1 /. {1 -> 0, 0 -> 1}) == Reverse[#2, 2](*mirror with respect to the 2nd column*)||
(#1 /. {1 -> 0, 0 -> 1}) == Transpose@#2(*diagonal*)||
(#1 /. {1 -> 0, 0 -> 1}) == Reverse@Transpose@Reverse@#2(*the other diagonal*)||
(#1 /. {1 -> 0, 0 -> 1}) == Reverse@Transpose@Reverse@Reverse[#2, 1]
(*mirror with respect to the 2nd row and first diagonal*)||
(#1 /. {1 -> 0, 0 -> 1}) == Reverse@Transpose@Reverse@Reverse[#2, 2]
(*mirror with respect to the 2nd row and other diagonal*)||
(#1 /. {1 -> 0, 0 -> 1}) == Reverse[Reverse[#2], 2]
(*mirror with respect to the 2nd row and the 2nd column*)
&];

-
This does not seem to account for permutations of the second component, which--according to the example--appear to be involved, too. (I have requested clarification from the OP concerning what is really meant by "permutation," because the question is currently ambiguous.) –  whuber Mar 10 '13 at 15:20
@whuber Given the fourth line in the first example (in the question), it seems the first line could be replaced by t2 = DeleteDuplicates[t, Total@#1 == Total@#2 &]; –  belisarius Mar 10 '13 at 15:29
@belisarius Right: that's the $S_9$ case, but because it results in only $5$ distinct tensors (upon accounting for the interchange of $0$ and $1$), it does not seem consistent with the OP's expectations. –  whuber Mar 10 '13 at 15:50
@whuber goodreads.com/quotes/… –  belisarius Mar 10 '13 at 15:54
Sorry about the ambiguity regarding "permutations." I'm not sure the most accurate way to describe it. Imagine taking a 3x3 array of 1's and iteratively changing each 1 to a 0 until you have an array of 0's. I consider a duplicate being an array that is identical under any rotation or mirror around any row or diagonal. j--'s solution is pretty close, although it still misses some. For example, if you do the following command (just to visualize it) you'll see that the 2nd and 5th arrays are the same. ArrayPlot[#, ImageSize -> 20, Mesh -> All] & /@ t3 –  dpholmes Mar 10 '13 at 21:08

In all my notebooks I use a few common customized functions. One is a generic and fault tolerant version of the solution to your question:

(* Eliminate duplicates of any permutation in a list *)
noDups@in_ := If[ListQ@in, DeleteDuplicates[
DeleteDuplicates@in,
If[#2 == {}, True, MemberQ[Permutations@#2, #1]] &], in];

It returns in if it is not a list and does a first order DeleteDuplicates@in before proceeding to eliminate the permutations.

Of course, the specific replacement rules (as given in the first answer) are not part of that common function.

-
Thanks for the tag wiki edits. :-) –  Mr.Wizard Mar 10 '13 at 18:35
By the way, I believe that there are more efficient ways to write your noDups function. For example: noDups2[other_] := other; noDups2[in_List] := GatherBy[in ~DeleteCases~ {}, Sort][[All, 1]] (Version 7 users will need to use Sort[#]& in place of Sort because of this bug.) –  Mr.Wizard Mar 10 '13 at 18:50
Could you give me an example of the failure, please? –  Mr.Wizard Mar 12 '13 at 2:09
the GatherBy code throws: Sort::normal: Nonatomic expression expected at position 1 in Sort[2]. (I thought I had a fix, but not yet...) –  J Gregory Moxness Mar 12 '13 at 2:21
I guess I didn't understand noDups as I had thought; what kind of input may this function receive? I had assumed a list of lists, though I didn't put that in the Pattern. –  Mr.Wizard Mar 12 '13 at 2:30

First, many thanks to @j--, his answer was both helpful and educational (the commented code was especially insightful).

This answer is in regard to the first part of the question. It requires checking for symmetry with respect to mirrors of the second row, the second column, and the two diagonals (thanks to @j-- for instruction. But, it also requires checking for symmetry by mirror of the second row and each diagonal, and mirroring about the second row and column (together).

The resulting code is (admittedly tedious and unoptimized):

t = Tuples[{1, 0}, {3, 3}];
t2 = DeleteDuplicates[
t, #1 == Reverse@#2(*mirror with respect to the 2nd row*)|| #1 ==
Reverse[#2, 2](*mirror with respect to the 2nd column*)|| #1 ==
Transpose@#2(*diagonal*)|| #1 ==
Reverse@Transpose@Reverse@#2(*the other diagonal*)|| #1 ==
Reverse@Transpose@
Reverse@Reverse[#2,
1](*mirror with respect to the 2nd row and first \
diagonal*)|| #1 ==
Reverse@Transpose@
Reverse@Reverse[#2,
2](*mirror with respect to the 2nd row and other \
diagonal*)|| #1 ==
Reverse[Reverse[#2],
2](*mirror with respect to the 2nd row and the 2nd column*)&];

This code results in 102 distinct arrays, which matches the original expectation (from doing it out by hand...).

The second part of this question is still unanswered, it should result in 51 distinct arrays.

-
I have updated my answer based on your solution by including a check for the similarity after the 0-1 substitutions. Now, I get 51 distinct arrays. –  j-- Mar 12 '13 at 7:16


text:
# The fastest thing since sliced cubes?

I've fallen down a rabbit hole recently, and need a reality check.

Suppose you have an arbitrary unit vector, $u \in \mathbf{R}^3$, and you cut up the unit cube into slices orthogonal to $u$ with width (measured along $u$) $\delta$. What are the volumes of the slices?

Here's what I mean:

(Each image shows every other slice. Code for creating the images is at the end of the question).

Seems like a simple enough question -- canonical, almost -- and here's a simple enough solution using ImplicitRegion:

cubevertices = Tuples[{0., 1.}, 3];
slicevolumeIR[v_, width_] := Module[{slicerange, slicepoints, slices},

(* Limits of the projection of the cube onto u *)
slicerange = MinMax[cubevertices.v];

(* Where the slices occur along u *)
slicepoints = Union[Range[Sequence @@ slicerange, width], {slicerange[[2]]}];

(* Find the slices as ImplicitRegions *)
slices =
ImplicitRegion[#1 <= {x, y, z}.v <= #2, {{x, 0, 1}, {y, 0, 1}, {z, 0, 1}}]
& @@@ Partition[slicepoints, 2, 1];

(* Find the volumes of the slices *)
RegionMeasure /@ slices
]

Then, for the example that generated the above figure,

u = Normalize@RandomReal[{-1, 1}, 3]
δ = 0.1;
AbsoluteTiming[
volumesIR = slicevolumeIR[u, δ];
]

(* {1.37398, {0.000903296, 0.00632307, 0.0171626, 0.0334219, 0.0550925,
0.0806039, 0.105649, 0.122993, 0.129516, 0.125199, 0.110043, 0.085887,
0.0601134, 0.0373954, 0.0200329, 0.00809016, 0.00156718, 7.61824*10^-6}} *)

Which is all well and good, but that took over a second and there were only 18 slices (as shown in the image... there's a tiny slice of leftovers at the top right of the plot on the right). I would like to be able to use this as part of a function to be fed into NMinimize as $u$ runs across a range, with on the order of several hundred slices. Clearly, RegionMeasure[ImplicitRegion[...]] isn't up to the task.

## So the question is...

What can I do to make it fast enough?

And, while we're on the subject,

How fast can it be done?

It feels like this should be straightforward -- it's just unit cubes and unit vectors, after all. How hard could it be? On the other hand, it's not like simple things can't be complicated. Which is why I need a reality check.

I've tried a number of improvements to the slicevolumesIR approach, the most successful of which I'll describe below. But it seems rather convoulted and verbose to me. I can't help feeling that there's still a lot more that could be done to simplify and speed up the process.

1. Are there ways to restructure the code to speed things up? (For example, I couldn't find a clean and effective way to use the Listable attribute, but that doesn't mean there isn't one).
2. Or ways to simplify the algebra or exploit mathematical structures that I've missed?
3. Or are there completely different, subtler ways of approaching the question? Can it be translated to some other mathematical framework that makes a solution more forthcoming?
4. Or is it just a more computationally complex problem than it first appears, and I'm waay overthinking it?

(Compiled and/or Parallelized code is fine. I haven't done either so far because I didn't want to use Compile to cover up inefficient code and I might want to save parallelization for the outer code. But if you can make use of it here, then it's fair game.)

## Cross section area approximation

The main observation here is that the volume of each slice of the cube is approximately proportional to the area of the cross section (orthogonal to $u$) down the middle of the slice (in a Riemann sum sort of way). Since the volume has to sum to 1, we can normalize these areas to get pretty good estimates of the slice volumes.

A couple of points about how I've gone about it:

1. I've hard-coded as much of the algebra as I can (cubeedges parameterizes the edges of the cube, and tvalues determines the values of those parameters for a particular cross section). So I can read off the points where a cross section cuts the edges of the cube and don't need to Solve anything.

2. After finding the vertices where the cross section intersects the cube edges, I project it onto a 2D subspace and find the area by direct calculation (in polyarea) rather than using RegionMeasure in 3D (which is slow).

3. I should also note that the function should to be able to cope with degeneracies in $u$, such as the possibility of it lying along an axis, and therefore not intersecting with some of the edges. (Hence the safedivide function.)

Set up some global variables for describing the cube:

cubevertices = Tuples[{0., 1.}, 3];
cubeedges = Function[t, #1 + t (#2 - #1)] & @@@
Select[Subsets[cubevertices, {2}], HammingDistance @@ # == 1 &];

Now a few helper functions:

safedivide[num_, denom_] := If[denom == 0, ∞, num/denom]

(* Calculate the values of t in cubeedgeeqns for which each edge
intersects the plane passing through projection points *)
tvalues[v_, projectionpoints_] :=
safedivide @@@ {{#, v[[3]]}, {#, v[[2]]}, {#, v[[1]]}, {# - v[[3]], v[[2]]},
{# - v[[3]], v[[1]]}, {# - v[[2]], v[[3]]}, {# - v[[2]], v[[1]]},
{# - (v[[2]] + v[[3]]), v[[1]]}, {# - v[[1]], v[[3]]},
{# - v[[1]], v[[2]]}, {# - (v[[1]] + v[[3]]), v[[2]]},
{# - (v[[1]] + v[[2]]), v[[3]]}} & /@ projectionpoints

(* Calculate the area of a 2D polygon embedded in R^3 by projecting
onto a 2D subspace orthogonal to u *)
polyarea[vertexlist_, orthobasis_] := Block[{
len = Length@vertexlist,
list2D = Transpose[vertexlist.# & /@ orthobasis],
slist2D},

(* Sort the vertices *)
slist2D = SortBy[# - Mean[list2D] & /@ list2D, ArcTan @@ # &];

(* Calculate the area of the polygon. Using Sum with Mod is faster than the
Det formula, and much faster than Area or RegionMeasure on Polygon*)
0.5 Sum[With[{j = Mod[i, len] + 1},
slist2D[[i, 1]] slist2D[[j, 2]] - slist2D[[i, 2]] slist2D[[j, 1]]],
{i, len}]
]

Putting it together:

slicevolume2D[v_, width_] := Block[{
vrange = MinMax[cubevertices.v],
orthobasis = Rest@Orthogonalize[Join[{v}, RandomReal[1, {2, 3}]]],
vpoints, tvals, crosssecvertices},

(* Find where the planes occur along v -- at the slice midpoints *)
vpoints = Mean /@ Partition[
Union[Range[Sequence @@ vrange, width], {vrange[[2]]}], 2, 1];

(* Find where the planes cut the cube edges *)
tvals = tvalues[v, vpoints];

(* Find the vertices of the cross sections *)
crosssecvertices = Union[#1[#2] & @@@
Pick[Transpose[{cubeedges, #}], 0 <= # <= 1 & /@ #] &@#,
SameTest -> (Chop[#1 - #2] == {0, 0, 0} &)] & /@ tvals;

(* Find the areas and Normalize *)
Normalize[polyarea[#, orthobasis] & /@ crosssecvertices, Total]
]

Try it out on the example from above:

AbsoluteTiming[
volumes2D = slicevolume2D[u, δ];
]

(* {0.00351377, Null} *)

Which is a pretty good improvement over the ImplicitRegion version, and fairly accurate

Max[Abs[volumes2D - volumesIR]]

(* 0.000443282 *)

(and accuracy will increase with the number of slices).

Plot the planes (code in Appendix):

## Benchmarks

Here's a comparison with a larger number of slices (288, as it turns out).

SeedRandom[12]
u = Normalize@RandomReal[{-1, 1}, 3];
δ = 0.005;
AbsoluteTiming[
volumesIR = slicevolumeIR[u, δ];
]

AbsoluteTiming[
volumes2D = slicevolume2D[u, δ];
]

(* {31.9965, Null}
{0.0572544, Null} *)

Compare the results:

Max[Abs[volumes2D - volumesIR]]
ListLinePlot[{volumes2D, volumesIR}]

(* 2.95272*10^-7 *)

So there is very good agreement, and slicevolume2D is over 500 times faster than slicevolumeIR. Still, I'm left wondering if it's overly complicated and there isn't a simpler/faster way to do this.

## Appendix 1: Code for the figures

Plotting the slices (for slicevolumesIR) or polygons (for slicecolumes2D) is simply a case of returning the regions instead of their computed measures. In the first case:

slicesIR[v_, width_] := Module[{slicerange, slicepoints},
slicerange = N@MinMax[cubevertices.v];
slicepoints =
Union[Range[Sequence @@ slicerange, width], {slicerange[[2]]}];
ImplicitRegion[
#1 <= {x, y, z}.v <= #2, {{x, 0, 1}, {y, 0, 1}, {z, 0, 1}}
] & @@@ Partition[slicepoints, 2, 1]
]

Then plot with

sliceregionsIR = slicesIR[u, δ];

GraphicsRow[{Show[
RegionPlot3D[#, Mesh -> None] & /@ sliceregionsIR[[1 ;; ;; 2]],
Graphics3D[{Thick, Arrow[{{0, 0, 0}, u}]}]],
Show[RegionPlot3D[#, Mesh -> None] & /@ sliceregionsIR[[2 ;; ;; 2]],
Graphics3D[{Thick, Arrow[{{0, 0, 0}, u}]}]]}]

Getting the slices from slicevolume2D is a little more complicated because we have to sort the vertices in 3D -- in slicevolume2D the vertices are sorted after being projected onto a 2D subspace.

slices2D[v_, width_] :=
Block[{vrange = MinMax[cubevertices.v], vpoints, tvals, crosssecvertices},
vpoints =
Mean /@ Partition[
Union[Range[Sequence @@ vrange, width], {vrange[[2]]}], 2, 1];
tvals = tvalues[v, vpoints];
crosssecvertices = Union[#1[#2] & @@@
Pick[Transpose[{cubeedges, #}], 0 <= # <= 1 & /@ #] &@#,
SameTest -> (Chop[#1 - #2] == {0, 0, 0} &)] & /@ tvals;
Polygon /@ (With[{centre = Mean[#], mp = Mean[#[[{1, 2}]]]},
SortBy[#,
ArcTan[Cross[# - centre, mp - centre].v,
(mp - centre).(# - centre)] &]
] & /@ crosssecvertices)
]

Then plot with

sliceregions2D = slices2D[u, δ];

Graphics3D[{sliceregions2D[u, δ], Thick, Arrow[{{0, 0, 0}, u}]}]

## Appendix 2: Update for @ybeltukov's answer

Here's the benchmark from earlier for @ybeltukov's sliceMeasure function. I am restricting sliceMeasure to a 3-dimensional unit cube fixed with origin {0., 0., 0.} and $u$ being a unit vector. Note that it works just as well on arbitrary $n$-dimensional parallelepipeds floating around in $\mathbf{R}^n$ with $u$ being whatever you like.

SeedRandom[12]
u = Normalize@RandomReal[{-1, 1}, 3];
δ = 0.005;

origin = {0., 0., 0.};
base = {{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}};
urange = MinMax[cubevertices.u];
dist = Union[Range[Sequence @@ urange, δ], {urange[[2]]}];

AbsoluteTiming[
volumes = sliceMeasure[origin, base, u, dist];
]

(* {0.000222371, Null} *)

It seems absurd to compare accuracy, since sliceMeasure doesn't make approximations in the same way that slicevolume2D does, and I have no reason to suppose that slicevolumeIR is more accurate than sliceMeasure (but Max[Abs[Differences[volumes] - volumesIR]] == 7.62888*10^-15, so they're very close).

To put those times into their proper context; sliceMeasure is about 143,888 times faster than volumesIR, whereas New Horizons (58,536 km/h) was merely 58,536 times faster than a sloth (1 km/h).

But that's not the half of it, since sliceMeasure really comes into it's own on longer lists:

timings = Table[
u = Normalize@RandomReal[{-1, 1}, 3];
urange = MinMax[cubevertices.u];
dist = Union[Range[Sequence @@ urange, δ], {urange[[2]]}];
{Length@dist,
First@AbsoluteTiming[slicevolume2D[u, δ]],
First@AbsoluteTiming[sliceMeasure[origin, base, u, dist]]},
{δ, 10^-Range[1, 6, 0.5]}
];

ListLogLogPlot[{timings[[;; , {1, 2}]], timings[[;; , {1, 3}]]},
Joined -> True, AxesLabel -> {"Number of slices", "Time"},
PlotLegends -> {"slicevolume2D", "sliceMeasure"}]

In summary: sliceMeasure is clearly "fast enough", and I'd be very surprised if any kind of significant speed increases were possible. But, more importantly, it is also an elegant mathematical formulation of the problem, and very concisely coded.

• Great work! I think it is already self-contained problem. However, I think little more info on the context of this question would be helpful. Nov 24, 2017 at 11:07
• @yarchik The original context was that I had this question rattling round in the back of my head, and eventually the question of slice volumes cropped up and took on a life of its own. So, although I might, in principle, use this code somewhere else, and that's my nominal reason for wanting the speed increase, my real motivation is that I feel like cutting up a cube should be a simpler problem than I've made it. Hope that clarifies things. Nov 24, 2017 at 21:18

## 1 Answer

There is a general problem of slicing $n$-dimensional parallelepiped by a hyperplane. Fortunately, it can be solved using the following piece of code:

sliceMeasure[origin_, base_, vec_, dist_] :=
With[{d = dist - vec.origin, c = base.vec, n = Length@base},
Total[Array[Ramp[d - {##}.c]^n (-1)^+## &, Table[2, {n}], 0],
n] Abs@Det[base/c]/n!];

The main idea is to sum up volumes of $2^n$ simplexes, which origins are located at corners of the parallelepiped with a proper choice of signs. In the above code, origin is the origin of the parallelepiped, base is the list of basis vectors of the parallelepiped, vec and dist specify the halfspace x.vec <= dist. The function is listable over dist, which greatly improves the performance.

In three dimensions, we can denote base as $({\bf b}_1,{\bf b}_2,{\bf b}_3)$, vec as $\bf v$, and dist - vec.origin as $d$. In this case, the volume of the intersection of parallelepiped and halfspace has a form $$V= V_0\sum_{i,j,k=0}^1(-1)^{i+j+k}\max(d-i {\bf b}_1\cdot{\bf v}-j{\bf b}_2\cdot{\bf v}-k{\bf b}_3\cdot{\bf v},0)^3,\\ V_0=\frac{1}{3!}\left|\det\left(\frac{{\bf b}_1}{{\bf b}_1\cdot{\bf v}},\frac{{\bf b}_2}{{\bf b}_2\cdot{\bf v}},\frac{{\bf b}_3}{{\bf b}_3\cdot{\bf v}}\right)\right|.$$

Let me demonstrate some examples:

SeedRandom[5];
dims = 2;
origin = RandomReal[1, {dims}];
base = RandomReal[1, {dims, dims}];
vec = RandomReal[1, {dims}];
dist = RandomReal[3];

RegionMeasure@RegionIntersection[Parallelepiped[origin, base],
HalfSpace[vec, dist]];
(* 0.144488 *)

sliceMeasure[origin, base, vec, dist]
(* 0.144488 *)

Graphics[{Red, Parallelepiped[origin, base], Blue,
Opacity[0.5], HalfSpace[vec, dist]}, Frame -> True]

SeedRandom[1];
dims = 3;
origin = RandomReal[1, {dims}];
base = RandomReal[1, {dims, dims}];
vec = RandomReal[1, {dims}];
dist = RandomReal[3];

RegionMeasure@RegionIntersection[Parallelepiped[origin, base],
HalfSpace[vec, dist]];
(* 0.0140496 *)

sliceMeasure[origin, base, vec, dist]
(* 0.0140496 *)

Graphics3D[{Parallelepiped[origin, base], Opacity[0.5],
HalfSpace[vec, dist]}]

Let us calculate volumes for $10^7$ different slices:

dist = 5 Rescale@N@Range[10^7];

(volumes = sliceMeasure[origin, base, vec, dist];) // AbsoluteTiming
(* {0.743143, Null} *)

Less than a second!

Here is the dependence of the volume as a function of the slice distance (we have too many points so we plot each 100-th point)

ListLinePlot[Transpose[{dist, volumes}][[;; ;; 100]],
AxesLabel -> {"distance", "volume"}]

P.S. the volume between two planes can be easily calculated as a difference for two different slices.

• I've added an update to the question with some comparisons for sliceMeasure. Very nicely done. Nov 27, 2017 at 12:57


text:
# All Questions

18,093,098 questions
Filter by
Sorted by
Tagged with
6 views

### deserialisation of maps and arrays if flutter with firebase as a backend

I am unable to deserialise a document map from firebase using flutter, I can deserialise single items but when I try to access a map object testMap:{hello:'Hello'} I get no value, I am just trying to ...
3 views

### Voice recognition failed miserably: Wrong status code 401 in Bing Speech API / token

When I was trying to translate a sample audio from English to some other language using Azure Bing Speech to Text Api, I am getting Error: Voice recognition failed miserably: Wrong status code 401 in ...
21 views

### How to run and watch local server at the same time?

I've been having some issues setting up my local server. I can get it to run with php artisan serve, but I can't add npm run watch at the same time. I've done npm install and updated my node too. It ...
7 views

### Difference between instance variable and non static member

I am studying C++ from different sources and I find confusing that sometimes I encounter the term "Non-static member" and sometimes the term "Instance Variable". For me, they can be used ...
11 views

### Select mysql data

I have query like this SELECT * FROM npcs_items WHERE id IN (SELECT shop_items FROM shops WHERE id = ?) But only output is 1 item, what is wrong?
12 views

### How to serialize and send object over network? (currently using cereal and winsock2)

I'm setting two projects (one is tcpServer, the other is tcpClient. EventManager is server side wrapper and have main, EventBusUtil is client side wrapper and also have main too.) In client, trying to ...
9 views

### How handle multiple textfields in cell and get textfield data

How to handle multiple textfields in a single row and also having one or more same type of cell which generates single cell per click on an outer button anywhere on controller in swift? Unable to ...
13 views

### #1064 - You have an error in your SQL syntax: add a primary key to my table admins

I want to add a primary key to my table admins But a get this error: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right ...
20 views

### android data binding error: cannot find symbol

I am trying to use Recycler and swipeRefreshLayout in my Main Activity but it just cannot find RecyclerView. This is my activity_main.xml <?xml version="1.0" encoding="utf-8"?> <layout ...
12 views

### How to redirect to a newly created object in Django?

I'm trying to redirect to the created object by filling the form below. I've tried the solutions that I found on these posts: How to redirect to a newly created object in Django without a Generic ...
5 views

I want to build the linphone-desktop project (cloned from https://github.com/BelledonneCommunications/linphone-desktop), but when I run git submodule sync && git submodule update --init --...
6 views

### Is there a way to use joyzoursky/python-chromedriver in other container?

I have a selenium test written in Python using headless Chromium. Now I'm trying to dockerize this test. I have found a great repository: https://github.com/joyzoursky/docker-python-chromedriver . It ...
6 views

### Splitting nested arrays as separate entities

I have some JSON data which contains attributes and some array elements. I would like to push a given set of fields into the array elements and then separate the arrays as separate entities. Source ...
7 views

### How to convert array of Highcharts to PDF in angular7?

I have an array of objects to render highcharts. Now I need to implement the functionality to convert an array of highcharts to pdf in a single pdf document.
12 views

### How to fix wrong format of number when writing df to csv?

I have a problem writing my pandas dataframe to CSV. I could not find a similar question in the other topics. In my command line output I have numbers varying from -4.5 to +4.5 and these numbers ...
11 views

### Will GLSL compiler remove unnecessary variable initialization?

For example, I have a code like this (fragment shader): Option 1 #version 330 core uniform sampler2D baseImage; in vec2 texCoord; out vec3 fragColor; void main() { fragColor = texture(...
5 views

### Computing classifier evaluation using confusion matrix

I trying to design classifier and compute its evaluation using confusion matrix, but all of the evaluation metrices resulted in a same result. My code is as the following: if system_decision == ...
4 views

### Can Queryql-playground be installed in Gatsby globally?

I would like to replace the default Gatsby Queryql feature with the newer QueryQL-playground. Can the change be made globally or does it have to be done on a per project basis? I have installed it on ...
21 views

### Why is my input validation from jquery wont work?

I want a validation onkeyup from an input form, I've made a jquery. I'm having a hard time finding why is it not checking? I need to go to a php page in checking. What could be wrong to my code that ...
5 views

### Response decoding failed with xmpp sasl authentication

I am trying complete the SASL authentication in XMPP server. I have connected to the xmpp server using gen_tcp socket I have registered a user 'test4' with password '123' Encode the username password ...
15 views

I have develop code on android to upload the image, but facing some errors in code. I search out solutions on internet but could not successful to fix the problems? The following code I have used: ...
12 views

### Test not running

simple code written in Visual Studio needs to be tested however the test doesn't return anything: no error, pass or fail. CODE: `public class Calculator { public int Add(int a, int b) ...
4 views

### Entries' DN missing the value in spring.ldap.base

I'm using spring-boot-starter-data-ldap to manager ldap entities. I set the property of spring.ldap.base which value is dc=tonny,dc=name, and then I created an entity class called LdapUser using the @...
25 views

### I have a main method, however I'm getting a Static Error: This class does not have a static void main method accepting String[] [on hold]

This is my code. It compiles but will not run and this pops up: "Static Error: This class does not have a static void main method accepting String[]".What is the issue and how can I fix it? Thanks ...
12 views

### Is it required to removeEventListener on an unmounted element/component?

If I attached event listener to a component, do I need to explicitly to remove it when it's unmounted? For e.g. componentRef = React.createRef(); handleWheel = (e) => { e....
15 views

I have a completely blank page, with the follow call to a js file: <script src="https://echarts.baidu.com/dist/echarts.min.js"></script> I am not able to even load the file, I get the ...
5 views

### Connecting to Impala from R without Impala JDBC driver

For an undisclosed reason, my Impala does not have a JDBC driver installed. This is making the connection from R to Impala challenging. I am able to connect (and query) to Impala shell via Putty. E....
7 views

### C# to pause, turn on ssas server, backup cube… how to?

I'm building some function apps in C# (via REST API) to make refreshes of tabular cube located on a azure ssas server. So far, no problem. However, I can't find a way to pause/start the ssas server (I ...
11 views

### Unable to set property of individual object

On using a local variable like I have used, I can set sizeSelect for a product in the mapped list and add another product to cart since sizeSelect changes.I want to give each product in the list a ...
8 views

### How to get Base64 image URL of Fusion chart in Angular 7

I am using Fusion chart in Angular 7 and i want to export this chart in Base64 Image format. I already used batchExport method. i am using this method for export chart in image format. app.component....
5 views

### How to use the workerData correctly when using worker threads without isMainThread?

I'm setting up a server and i'm trying to use working threads in it, for some reasons, I can't use the the same file for the main thread and the worker thread (pass __filename at new Worker), so I'm ...
16 views

### Why Named Function Expression itself cannot assign Name to another Value? [duplicate]

var functionVariable = function functionExpressionName() { functionExpressionName = 1; console.log(functionExpressionName) // function }; functionVariable(); If You run this example you can ...
17 views

### C++: Creating a new objects inside a function and copy him to another object class

I have question which have confused me for a while. I did do some searching online and read through much c++ tutorials, however I cannot find concrete answers. I have a class named 'Word' which look ...
5 views

### uWSGI server sometimes hung up for unknown reasons

Problem I've operated Django + uWSGI apps for a year on AWS, and it was working well until two weeks ago, but I run into the problem that the specific uWSGI process sometimes hung up and rarely ...
6 views

### email working on local server but not working on live server AWS using zf3

Description: sending mail from localhost mail working but sending from AWS server mail not working giving error below as i mentioned. Code: $options = new SmtpOptions();$options-&...
22 views

### cannot cast 'android.support.v4.app.Fragment' to 'com.google.android.gms.maps.SupportMapFragment'

I created one new project with google maps activity and i installed google play services. I added the permissions of internet,fine location and coarse location. I copied the URL which is mentioned in ...
18 views

### How to reset scroll position on single page pagination

I try to fix scroll location. When clicking on another pagination, scroll location does not be reset. Front : React css framework : semantic-ui-react Paragraph = () => ( <p style={{...
9 views

### What's the difference between a page load in a new tab or in a new window ,in terms of modal popup form functionality

Mvc modal popup form doesn't work when the page is opened as a new tab ,But its works when the page is opened as new window In Main page, I have dynamic tab which loads #Rep_Contracts , And in #...
7 views

### Is there a way to sort strings inside an array, based on parts of the string?

I'm trying to program a simple Italian dictionary. I want to be able to sort by parts of the string. I'm keeping the Italian, English, and information together. Here's a link to the full code: https://...
6 views

### XML Tag Replacement using Python

I have a xml file as shown on below. Recently started working on Python. I need to replace the ... element to .... I have a coding but it replaces the closing element too. Please advice. XML File: &...
9 views

### LaTex document does not show up correctly

I am following an example for LaTex documentation in markdown and it begins with the following : \documentclass{article} \begin{document} Hello, \LaTeX! \end{document} when I run the cell, I ...
10 views

### Generating random Bootstrap patterns [on hold]

For my research project, I need templates of webpages with Bootstrap and their screenshot, templates are in HTML format and are composed of different Bootstrap elements (navbar, cards, ...) in a ...
12 views

### Can I use “model.fit()” in “for” loop to change train data in each iteration

I have a large dataset and it doesn't fit in memory. So while training, SSD is used and epochs take too much time. I save my dataset 9 part of .npz file. I choose first part (part 0) as validation ...
3 views

### Read multiple TFRecord files with keras::tfrecord_dataset

I am getting started with Keras, and would like to create a dataset from multiple TFRecord files. Below is the code I have so far. dataset <- tfrecord_dataset(filenames) %>% dataset_map(...
5 views

### Vuex - mapGetters et al but mapping by parameter

I'm trying to create a general filter component which get's it's data from the store Right now, I'm using mapGetters like so ...mapGetters({ items: 'filters' }), But I would like to be able to ...
10 views

### How to initialise 'MutableMap' from constructor of data class in kotlin?

I have a data class which has a constructor like this (source): data class MyDataClass ( val myArr: ArrayList<Char> ) { constructor(n: Int): this( ArrayList((0 ...
18 views

### shell using multiple if elif, I cannot make it work [duplicate]

I am a newbie in bash writing. I need to use a bash file to create a program in Stata (using printf). My problem, though is in the initial if, elif, then condition. I first run the following bash !./...
7 views

### Is there blackhat morphological Method in “Jimp” that I can apply on image?

I'm trying to prepare image to be ready for tesseract.js and I'm using Jimp for that. So I need something like Blackhat morphological Method to convert image like this to something like this If you ...


text:
# Doubling Your Rate: A Thought Experiment

What would happen if tomorrow I forced you to double your rate?

If you bill hourly, your rate just doubled. If you bid by the project, you have to bid twice as much as usual. If you sell a product on the side (Wordpress theme?), you have to double its price too.

For the sake of exploration, let's ignore the understandable backlash from existing customers. Instead, let's focus on the more interesting question:

What would you have to do to justify the rate?

Don't escape the question by saying "That's impossible." I don't care that there are crowd-sourced workers in Malaysia who can replicate all of Microsoft Office for $17.32. You already compete against them, and being 10x as expensive is the same as being 20x as expensive. For everyone billing$50/hour there's someone billing $100/hour and another billing$25/hour. It's possible -- the question is: How would you do it?

If you can answer the question, it could transform your freelance business. You could raise rates significantly. Or, if you just acted like a person worth twice as much money, you'd blow away the competition.

Here's some ways to act like you're worth twice as much money.

I know a freelancer who charges $110/hour for writing whitepapers and website copy. How does she get away with it? She earned it by becoming an expert. She's focused on high-tech messaging and marketing. She doesn't list a myriad of services she could provide, she talks about how her marketing knowledge leads to more revenue. She only takes high-tech clients. She writes a high-content blog which she uses to demonstrate that she's a thinker, not just a wordsmith. She gives talks about high-tech marketing. "Expertise" is the key word here. Not general, specific. Not broad/shallow, but narrow/deep. To be specific, here's what an expert looks like versus what a generalist looks like: • Works for just one, well-defined category of customer / Works for anyone with money • Can summarize specialization in one sentence / Can't decide what "one thing" defines him • Publishes regularly with new insights / Doesn't leave evidence of original thinking • Emphasizes tangible results from previous customers / Lists certifications and shows portfolio without context • Blows clients away with depth of knowledge / Blows clients away with breadth of skills • Sends quarterly newsletter to customers and prospective customers with interesting information and ideas / Sends automated greeting cards on birthdays and holidays • Has one detailed case study on the massive effect she had on a customer's business / Has 10 decent testimonials on LinkedIn Being a generalist could sound appealing because you feel like you're not "closing any doors." But the tighter and stronger you define your niche, the more valuable you become to the folks who are in that niche. ### Look the part Some call it "a sad commentary on the shallowness of human behavior," others call it "marketing" -- you are a book, and you'll be judged by your cover. Lexus and Toyota are the same company. The difference between the lowest-end Lexus and the highest-end Toyota is negligible; indeed, next year's high-end Toyota will be last year's Lexus. So what justification is there for a Lexus to be far more expensive than a Toyota? It's branding -- the shallowest type of marketing. It's not content, it's not quality, it's not data, it's just that Lexus has an "expensive brand" and Toyota is the "quality, hoi-polloi" brand. How does this apply to you? • Does your website look stylish and designed, or Web 1.0? Ironically designers often neglect their own website, too busy (understandably) working on paying gigs. Writers are often the most guilty. • Do you show up to your interview/first-meeting in nice clothes? Not a stuffy suit (unless you live in a place like NYC or Boston where suits are expected), but not just street clothes. • This doesn't mean you should be slick, garish, or flaunty. "Expensive" doesn't necessarily mean wearing diamond cufflinks -- in fact it can work against you to look like you have a lot of extra money to spend. Being worth a lot of money is different from proving you have a lot of money. ### Give little gifts of time All freelancers struggle with the balance between when to charge and when not to. For example, if a client sends you a short email requiring a short response, do you start the clock? On one hand, context-switching is expensive, little emails can add up, little tasks sometimes turn into big tasks before you know it, and you don't want to establish a precedent of working for nothing. On the other hand, it's chincy to charge for every little thing, waiting for emails to pile up might not work with your client's time constraints, and you know it answering emails quickly makes a good impression. When your hourly rate is low, this is a real problem. No solution is terrific -- each choice leaves something to be desired. But with a high rate, it's not so hard. Yes, lawyers charge you just for reading a Tweet (rounded up to nearest 15 minutes of course, plus copy-paper charges for having to print out the Tweet and admin costs for having to file the Tweet), but you don't need to do that. At$100+/hour, doing the standard, on-the-clock tasks add up fast, especially if you round to 15 minutes.

And another thing: By establishing a high rate but not charging as many hours, the customer gets over the sticker shock once (when they hire you), but will repeatedly be thrilled with the fact that you don't over-bill them for hours.

Finally, for a client that starts slow but then has a bigger project for you, you've established a high base-price for future negotiations.

### So, what now?

Now that the juices are flowing -- you probably have more ideas, plus here's 5 more -- what can you do with this high-priced mindset?

1. Raise rates! If you act like you're worth it, aren't you worth it? (Here's how to handle existing clients.)
2. Get business even in a recession by being more valuable for the same money.
3. Blow away competition by being more valuable for the same money.
4. Take advantage of the virtuous circle: Writing expert articles and offering to speak gets you guest-posting and speaking gigs which gets you attention and clients which get you more material which ...

Do you have more ideas for how to be worth a higher rate? Leave a comment and join the conversation!


text:
• You might run into the problem where gnome-keyring-daemon didn't start.
A workaround for me was to uninstall dbus-user-session.


text:
# Paradox which questions time travel to the future

1. Aug 1, 2009

### The Hater

You all have heard of the paradox whereas when you travel to the past and kill your grandfather you should not have existed in the presence whatsoever because you have killed your origins. So far so good...but I thought of another case, which I believe is more interesting since so far the Einstein's equations of time dilation seriously question time travel to the past....but with the paradox I just thought about - even time travel to the future might be seriously under question(not really...I will explain below), but before that - here is the paradox itself:

Imagine that one day time travel to the future is possible.
Given such temptation everyone will like to see the distant future...but at the same time we know that travel to the past is not possible - due to the "grandfather paradox" and because if it was possible, the speed PERHAPS will exceed speed of light, since this is what is shown according to the time dilation simple equations. Now...that means that when you teleportate yourself to the distant future - this is it...there is no way back - you can either stay there or if you don't like it....go even further :). Such as if you don't like 2025...then teleport once again - this time to 2125 hoping that this year will be better(women will be more beautiful). Now...what happens when all people from the present time chose to go to the future? Well...what happens is that if all people go to 2025 - then there will be NO people that have lived in the period 2009-2025, hence the year 2025 will NOT be possible. This is the paradox ;).
Now...a few corrections actually - if all people decide to go to the distant future - then this is actually possible, but since all people have done this - they will see no advance in future.
Here is what happens: If you were the only one to go from 2009 to 2025 - then from the point of view of the people living in 2025 - you would have dissapeared somewhat in the past and the just came out otta the f*** nowhere. If on the other hand you and another 1000 people do the same - then the effect will be the same - only on larger scale. Finally...what happens if today everyone on earth decides to go the year 2025? Well...when we "arrive" in 2025 - we will discover that the only thing which has changed from 2009 to 2025 is actually the trees and the animals :) - since there are no living humans from 2009 t0 2025.
In other words - it will be better if just you and a few friends can travel to the future - since this way you will see immediately what has changed thorough the years that have passed in the meanwhile - otherwise if all people on earth make the jump - then only trees and animals would have been changed :). This is the interesting "paradox" - it's not a paradox in the sense that this doesn't reject the possibility to time travel to the future - but it's interesting to be noted that this is the same like a gold formula - the more people the gold formula - the less valuable it is - if only you knew how to time travel - you can go to the year 2500 and see better computers and hotter girls.

The good news is that neither the "grandfather killing paradox" nor this paradox that I just presented actually question time travel. How come??? Well...the human mind fails to understand that when you change time you change another dimension and there are actually not just 10 or 11 :)...but literally infinite amount of dimensions - so each time you travel you literally create a new reality. Need proof? Well...when the astronauts go to space and come back, they comeback younger. Here is another proof - when object is moving faster and faster it's mass is changed due to...speed. Since mass(ok "energy"...what a word...) can be changed - then as it follows time can be too...it's just a matter of time :).

2. Aug 1, 2009

### The Hater

In other words, the simple time dilation equation:

t' = t*√(1-v2/c2)

If you turn the equation a little bit:

t = t'/√(1- v^2/c^2)

If you want to travel to the year 2104, travelling 12 hours in total, then:

2104 = 43200/√(1- 89875517855706660/89875517873681764)

whereas:
43200 are seconds;
89875517855706660 is speed we are travelling to on 2nd power ;
89875517873681764 speed of light to the 2nd power...);

And here we assume NO acceleration, which is actually not a big problem either.

How time is changed with respect to our speed is(...the derivative...):

Finally, I wrote a short PHP script which lets you calculate the time dilation above...IFthis thread reseives any interest rather than stupid mods changing the category...I will give also C sharp code for a windows application so you can just download it and plug it yorself ;):

The PHP code...for the programmers...just change the numbers and you'll get it...once again...if the thread has any interest later: I will provide a more ser friendly code in c sharp...as a windows form + .exe downloadable file for anyone to download and use it right away not just the programmers.:

<?

$t= 43200;$some=(1- 89875517855706660/89875513077002500);
$t1 =$t*sqrt($some);$z= $t /sqrt($some);

echo "$t1<br>"; echo "$z";

?>

3. Aug 1, 2009

### The Hater

Also....if you want to know "At what speed do I need to travel to go to some year?"

Such as if you want to determine the speed needed to go to the year 2050, travelling a day - then:

(2050 - 2009)*365*(1 - 0.5753424657534246/(2050 - 2009)) = 1/Sqrt[
1 - (x*299792458)^2/299792458^2]
14755 = 1/Sqrt[1 - x^2]
Sqrt[1 - x^2] = 1/14755
Sqrt[1 - x^2] = 0.00006777363605557438
x = Sqrt[1 - 0.00006777363605557438^2]

Which is again about 0.9999 and some more digits the speed of light.
So abot 0.9999*c again.

But, consider that this equations does NOT take into account the fact that 365 days per year are not constant - at least not once in every 4 years :). You can easily change this by adding one-2 things within the equation though...of course.

4. Aug 1, 2009

### junglebeast

We already know from relativity that the speed you travel through time is related to the speed you move through space -- so yes, you can travel to the future. Everyone's doing it. We also know that the speed you travel through space cannot exceed the speed of light, and this puts an upper bound on the speed that you can travel through time.

The universe does not think through possibilities and decree certain things impossible because a paradox may exist. Rather, paradoxes are an indicator that your assumptions are contradictory. In this case I believe that the grandfather paradox is simply a consequence of the fact that time is a measurement of change in state rather than a space-like dimension, and change has no notion of sign -- therefore it is a logical contradiction to go backwards in time, just as it is a logical contradiction to have a positive number less than -1. It is only out of mathematical convenience that we choose to represent time as a 4th dimension, but this is just because in mathematics any arbitrary set of 4 numbers can be referred to as "dimensions."

Last edited: Aug 1, 2009
5. Aug 1, 2009

### leroyjenkens

No, they come back older. Just only a few nanoseconds younger than they would have normally aged sitting on Earth.

6. Aug 1, 2009

### negitron

There is exactly zero evidence of this. It's just a scientific speculation which doesn't even rise to the level of a hypothesis, let alone a theory. Asserting statements is not "proof."

7. Aug 2, 2009

### Ivan Seeking

Staff Emeritus
In fact it is crackpottery that will get a person banned very quickly.

8. Aug 3, 2009

### imiyakawa

Lol best word.

9. Aug 3, 2009

### cristo

Staff Emeritus
This thread seems speculative, at best, and so is done.


text:
# zbMATH — the first resource for mathematics

A characterization of essential sets of function algebras. (English) Zbl 1115.46041
Let $$X$$ be a compact topological space. A function algebra $$A$$ on $$X$$ is any closed subalgebra of the Banach algebra of continuous complex-valued functions on $$X$$. The following statement is the main result of the paper.
Let $$A$$ be a function algebra on $$X$$. Denote by $$E$$ its essential set. Let $$x\in X$$. Then $$x\in X\setminus E$$ if and only if there exists a closed neighbourhood $$V$$ of $$x$$ in $$X$$ such that the following two conditions are fulfilled:
(1) $$A/V=C(V)$$, where $$A/V$$ means the algebra of all restrictions of functions from $$A$$ to the set $$V$$;
(2) $$V$$ is an intersection of peak sets of $$A$$.
Note that the concept of essential set was introduced by H. S. Bear [Trans. Am. Math. Soc. 90, 383–393 (1959; Zbl 0086.31602)]. Roughly speaking, a set $$E\subset X$$ is the essential set of a function algebra $$A$$ if it is the maximal set with the property that $$A$$ consists of all continuous extensions of functions in the algebra of restrictions $$A/E$$.
##### MSC:
 46J10 Banach algebras of continuous functions, function algebras
##### Keywords:
function algebra; essential set
Zbl 0086.31602
Full Text:


text:
Volumes by Cylindrical Shells (Calculus II)

shamieh

Active member
Quick question, may seem rather dumb - but I just want to make sure of something..

Question: Find the volume of the solid obtained by rotating about the y axis the region between y = x and y = x^2

so when I am setting up my integral am I correct in saying $$\displaystyle TOP - BOTTOM i.e. --> \int^1_0 (2\pi x) (x - x^2) dx$$?

Ackbach

Indicium Physicus
Staff member
Re: Volumes by Cyllindrical Shells (Calculus II)

It looks good to me. The $2\pi x$ gives you the length of a shell, were you to straighten it out. The $x-x^{2}$ gives you the height of a shell, and the $dx$ gives you the thickness.


text:
# Exam-Style Questions on Volume

## Problems on Volume adapted from questions set in previous Mathematics exams.

### 1.

GCSE Higher

The diagram, not drawn to scale, shows the plan for a large, three dimensional sign which has been ordered to hang outside an ice cream shop.

The sign is made of a hemisphere on top of a right cone.

The height of the cone is 2 m.

The top of the cone has a diameter of 1 m.

The hemisphere has a diameter of 1 m.

The total volume of the shape is $$k \pi$$ cm3, where $$k$$ is an integer.

Work out the value of k.

## Useful formulas

$$\text{Volume of a sphere} = \frac{4 \pi r^3}{3}$$

Where $$r$$ is the radius of the sphere.

$$\text{Volume of a cone} = \frac{\pi r^2 h}{3}$$

Where $$r$$ is the radius of the circular end of the cone and $$h$$ is the height of the cone.

### 2.

GCSE Higher

A container is in the shape of a cuboid as shown in the diagram below.

The container is three quarters full of water.

A glass holds 250 ml of water.

What is the greatest number of glasses that can be completely filled with water from the container?

### 3.

GCSE Higher

The diagram shows a rectangular-based pyramid, TABCD (not drawn to scale).

The horizontal base ABCD has sides of lengths 11m and 15m. The centre of the base of the pyramid is M.

Angle TMC is 90° and angle TCM is 70°

The volume of a pyramid is $$\frac13$$ × area of base × perpendicular height. Calculate the volume of this pyramid.

### 4.

IB Applications and Interpretation

A wedge is to be cut from a log in the shape of a cylinder as shown in the diagram below (not to scale).

The length of the log is 240cm and its radius is 40cm. The cross section of the wedge to be removed is a sector with an angle of 130o.

What is the volume of the remaining piece of the log after the wedge has been removed?

If you would like space on the right of the question to write out the solution try this Thinning Feature. It will collapse the text into the left half of your screen but large diagrams will remain unchanged.

The exam-style questions appearing on this site are based on those set in previous examinations (or sample assessment papers for future examinations) by the major examination boards. The wording, diagrams and figures used in these questions have been changed from the originals so that students can have fresh, relevant problem solving practice even if they have previously worked through the related exam paper.

The solutions to the questions on this website are only available to those who have a Transum Subscription.

Exam-Style Questions Main Page

Search for exam-style questions containing a particular word or phrase:

To search the entire Transum website use the search box in the grey area below.